I have a Customers table which looks like the following:
Customers
Name ID Number of Purchases
Billy 100 2
Steve 101 1
Alison 102 5
John 103 3
Matt 104 0
Andrew 105 1
I have a standard Date dimension
Date Month Year
1/1/2017 January 2017
1/2/2017 January 2017
1/3/2017 January 2017
1/4/2017 January 2017
...
2/1/2017 February 2017
2/2/2017 February 2017
2/3/2017 February 2017
2/4/2017 February 2017
I have a Purchases table
Purchases
Date Name ID Amount
1/1/2017 Billy 100 10.53
1/1/2017 Alison 102 15.90
1/2/2017 Alison 102 9.87
1/3/2017 Steve 101 12.59
1/4/2017 Billy 100 22.19
1/4/2017 John 103 17.45
1/5/2017 John 103 8.79
2/1/2017 Alison 102 9.87
I am trying to develop something where every customer get's thrown into a bin based on the number of purchases they have made in the selected date range.
So if I select 1/1/2017 - 1/2/2017, I should only have 2 bars. The first bar should have a 1 on the x axis with a value of 1 because "Billy" made 1 purchase in the selected time period, and the second bin will be 2, and it will also have a value of 1 because "Alison" made 2 purchases in the selected time period. IF I put [Number of Purchases] on the x-axis and then use
NameCount = CALCULATE( COUNT(Purchases[ID]), FILTER(Purchases, Purchases[ID] = RELATED(Customer[ID])))
for the values, it tells me there are 3 people with 5 purchases, but that is not true. In reality, no one actually has 5 purchases on the Purchases table. Alison is in the lead with 3 purchases.
To accomplish this I am planning on using a stacked column chart, I just don't know what to use for the Axis and Values. The Axis only allows me to use a static column, which would be fine, but I could have customers with 50 purchases.
I think the answer is going to be to develop a calculated table, but I've never done that before so I'm not sure how/if that will work.