Calculating YOY Growth

K

KrispyData

Hi.
I have AllSales table with following fields:
Product
FiscalQuarter
FiscalYear
FiscalYearFiscalQuarter(FYFQ)
SalesAmount

I want to calculate 2009-2008 growth with the following expression:
(2009Sales-2008Sales)/2008Sales

Here's what I did:

Created two almost identical queries (only difference is filtered on 2009 or
2008):
qry2008Sales
qry2009Sales

both queries have the following fields from AllSalesTable:
Product
FYFQ
SalesAmount

I joined the two queries by Product.
Then, I created another query using the above queries.

In the design grid, I put the fields:
Product, FYFQ, SalesAmount, and the YOY Growth expression

The results for my expression are #Error
What did I do wrong?
 
K

KARL DEWEY

Try this --
SELECT Product, Sum(IIF([FiscalYear] = "2008", SalesAmount, 0)) AS
[2008Sales], Sum(IIF([FiscalYear] = "2009", SalesAmount, 0)) AS [2009Sales],
Sum(IIF([FiscalYear] = "2009", SalesAmount, 0)) - Sum(IIF([FiscalYear] =
"2008", SalesAmount, 0)) AS [YOY Growth]
FROM AllSales
GROUP BY Product;

If your FiscalYear field is a number and not text then remove the quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top