Hey guys,
I'm a newby here. Im programing an Access as follows:
I have 1 table called indices with the fields Month,DRS, 3-Month Treasury, Lehman Bros Agg Bd Index, Lehman Bros 1-3Y US Treas, Lehman Bros 7-10Y US Treas, Lehman Bros. 20+Y US Treas, JPMorgan EMBI+, SP 500 Index.
Each filed has 39 observations. First of all I created a Query Called BalancedAllocation as follows:
SELECT Indices.Month, Sum(Indices![3-Month Treasury]*0.05+Indices![Lehman Bros Agg Bd Index]*0.45+Indices![SP 500 Index]*0.5) AS BalancedAllocation
FROM Indices
GROUP BY Indices.Month;
Then I created a Query called BullDJWA as follows
SELECT Indices.Month, Sum(IIf(Indices![SP 500 Index]>=0,1,0)) AS BullDJWA
FROM Indices
GROUP BY Indices.Month;
Then I had to create another query called BearDJWA that uses the query BullDJWA as follows:
SELECT Indices.Month, Sum(Abs(Bull_DJWA!BullDJWA-1)) AS BearDJWA
FROM Bull_DJWA
GROUP BY Indices.Month;
SO THE FIRST QUESTION IS: Can i create the BearDJWA in the same query as the BullDJWA?
Then i had to create a binary column using IIF from all the fields in the table indices. Creating a query separated for each field qould look like this using the 3-month trasury example:
SELECT IIf(Indices![3-Month Treasury]<0,1,0) AS [3-Month Treasury]
FROM Indices;
SO HERE IS THE SECOND QUESTION: I tried to create all "IIF" in one big query and the resoult was funny. I used this formula:
SELECT IIf(Indices!DRS<0,1,0) AS DRS, IIf(Indices![3-Month Treasury]<0,1,0) AS [3-Month Treasury], IIf(Indices![Lehman Bros Agg Bd Index]<0,1,0) AS [Lehman Bros Agg Bd Index], IIf(Indices![Lehman Bros 1-3Y US Treas]<0,1,0) AS [Lehman Bros 1-3Y US Treas], IIf(Indices![Lehman Bros 7-10Y US Treas]<0,1,0) AS [Lehman Bros 7-10Y US Treas], IIf(Indices![Lehman Bros 20+Y US Treas]<0,1,0) AS [Lehman Bros 20+Y US Treas], IIf(Indices![JPMorgan EMBI+]<0,1,0) AS [JPMorgan EMBI+], IIf(Indices![SP 500 Index]<0,1,0) AS [SP 500 Index], IIf(Balance_Allocation!BalancedAllocation<0,1,0) AS BalancedAllocation
FROM Indices, Balance_Allocation;
and instead of giving me the resoult for the 39 observations it gave me 1521. I dont have a clue why???
And the THIRD QUESTION: I have to make this excel formula: =PRODUCT(1+O4:O42)^(12/COUNT(O4:O42))-1 in another query. Could somene help me out with the SQL code??????????
Im starting to think that maybe it will be easier to make it on VB.
What do you guys think. I appreciate all the help.
REgards
I'm a newby here. Im programing an Access as follows:
I have 1 table called indices with the fields Month,DRS, 3-Month Treasury, Lehman Bros Agg Bd Index, Lehman Bros 1-3Y US Treas, Lehman Bros 7-10Y US Treas, Lehman Bros. 20+Y US Treas, JPMorgan EMBI+, SP 500 Index.
Each filed has 39 observations. First of all I created a Query Called BalancedAllocation as follows:
SELECT Indices.Month, Sum(Indices![3-Month Treasury]*0.05+Indices![Lehman Bros Agg Bd Index]*0.45+Indices![SP 500 Index]*0.5) AS BalancedAllocation
FROM Indices
GROUP BY Indices.Month;
Then I created a Query called BullDJWA as follows
SELECT Indices.Month, Sum(IIf(Indices![SP 500 Index]>=0,1,0)) AS BullDJWA
FROM Indices
GROUP BY Indices.Month;
Then I had to create another query called BearDJWA that uses the query BullDJWA as follows:
SELECT Indices.Month, Sum(Abs(Bull_DJWA!BullDJWA-1)) AS BearDJWA
FROM Bull_DJWA
GROUP BY Indices.Month;
SO THE FIRST QUESTION IS: Can i create the BearDJWA in the same query as the BullDJWA?
Then i had to create a binary column using IIF from all the fields in the table indices. Creating a query separated for each field qould look like this using the 3-month trasury example:
SELECT IIf(Indices![3-Month Treasury]<0,1,0) AS [3-Month Treasury]
FROM Indices;
SO HERE IS THE SECOND QUESTION: I tried to create all "IIF" in one big query and the resoult was funny. I used this formula:
SELECT IIf(Indices!DRS<0,1,0) AS DRS, IIf(Indices![3-Month Treasury]<0,1,0) AS [3-Month Treasury], IIf(Indices![Lehman Bros Agg Bd Index]<0,1,0) AS [Lehman Bros Agg Bd Index], IIf(Indices![Lehman Bros 1-3Y US Treas]<0,1,0) AS [Lehman Bros 1-3Y US Treas], IIf(Indices![Lehman Bros 7-10Y US Treas]<0,1,0) AS [Lehman Bros 7-10Y US Treas], IIf(Indices![Lehman Bros 20+Y US Treas]<0,1,0) AS [Lehman Bros 20+Y US Treas], IIf(Indices![JPMorgan EMBI+]<0,1,0) AS [JPMorgan EMBI+], IIf(Indices![SP 500 Index]<0,1,0) AS [SP 500 Index], IIf(Balance_Allocation!BalancedAllocation<0,1,0) AS BalancedAllocation
FROM Indices, Balance_Allocation;
and instead of giving me the resoult for the 39 observations it gave me 1521. I dont have a clue why???
And the THIRD QUESTION: I have to make this excel formula: =PRODUCT(1+O4:O42)^(12/COUNT(O4:O42))-1 in another query. Could somene help me out with the SQL code??????????
Im starting to think that maybe it will be easier to make it on VB.
What do you guys think. I appreciate all the help.
REgards