I am trying to use a Switch formula in a query so that I can list results in the query horizontally by month. However I am having a lot of trouble with it. The only way I can get the query to run is to enter the formula like this:
Unfortunately, when I do that for each month (changing the Month_Num for each month), the query gives me the same total for every month. I tried entering this formula
, but then I get an error message stating that "you tried to execute a query that does not include the specified expression IIf(Switch(CInt([WIP_MONTH_NUM])=1,2)=2,Sum([WIP_AMOUNT]),' ') as part of an aggregate function." I also tried just using a straight IIF statement, but received the same error message. In the Totals row, I have this column listed as an expression. The Group By is on the Part Number.
How can I get this query to work? I got it in a pivot table, but I'm going to want to export the results of the query into an Excel sheet, and I'm not sure that the pivot table will work for that. Any advice you can provide would be greatly appreciated.
Code:
Mar_Totals: IIf(Count(Switch([WIP_MONTH_NUM]='03',1))=1,Sum([WIP_AMOUNT]),' ')
Unfortunately, when I do that for each month (changing the Month_Num for each month), the query gives me the same total for every month. I tried entering this formula
Code:
IIf(Switch(CInt([WIP_MONTH_NUM])=3,1)=1,Sum([WIP_AMOUNT]),' ')
How can I get this query to work? I got it in a pivot table, but I'm going to want to export the results of the query into an Excel sheet, and I'm not sure that the pivot table will work for that. Any advice you can provide would be greatly appreciated.