I'm running two queries:
Query 1 pulls two columns [Sales Rep] and [Account Name] and is a comprehensive list of all accounts which are able to sell merchandise.
Query 2 pulls in four columns [Sales Rep], [Account Name], [Invoice Date], [Invoiced Amount] and only contains accounts which have had a sale in the last two years.
I merged the queries on the sales rep and account name column to produce a list of all accounts regardless if they have made sales or not. I created a variable dimension called [Sales Growth] which uses nested IF statements to say whether the account was a growth, decline, etc. This variable has a ForEach([Sales Rep];[Account Name]) in it.
Next I wanted to create a count for each category. Say I pick Sales Rep #1 as a filter, it should say 2-Growth, 5-Shrink, 3-Maintain, etc. So for my count variable I used
=Count([Account Name] ForEach([Sales Rep];[Account Name];[Sales Growth]))
The problem is that the count is ignoring some accounts! In the case where accounts do not have any sales this year, or last year, the count doesn't even pick them up.
As you can see in my example, the correct count should be 2 Shrink, 3 No Sales, 2 Growth. Instead, two accounts had no sales in in both years so for some reason the count isn't working. I've tried every way to make this work.
I need the count to ultimately work in the format below so it can be displayed correctly in a pie chart.