Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have a dataset which has a numerical column which mentions number of purchases made. Along with this, I do have the month in which the purchase is made and also the customer who did the purchase.
Now I have something like 5 years worth of data with me and I need to come up with a measure which will display how many purchases were made by each customer in each month.
So if the data is something like
Date Category Purchases Customer
1/1/2015 A 2 1
1/1/2015 B 3 1
1/2/2015 A 1 1
1/2/2015 B 5 1
1/1/2015 A 1 2
I need the final output to be
Date Purchases Customer
1/1/2015 5 1
1/1/2015 1 2
1/2/2015 6 1
I have already aggregated the purchases by month using the measure below
CALCULATE(SUM([Purchases]), FILTER(ALL(Table), ([Date]) = (MAX([Date]))))
I am using this measure inside a calculated column on the table above and this is giving me the total purchases made in a month irrespective of the customer. Now how do I further slice it down to the customer level ?
Solved! Go to Solution.
Actually, I was thrown off by your formula earlier because it's giving you the total purchases for the last month, not actually disagregating by every month, so didn't get what you were going for. But I get it now (I think). The following will work in a calculated column:
CalcColumn= CALCULATE( SUM('Table'[Purchases]), FILTER('Table', 'Table'[Date] = EARLIER('Table'[Date]) && 'Table'[Customer] = EARLIER('Table'[Customer]) ) )
All that said, it sounds like this would be more appropriate to go in a measure. I.e. if you want to know for each month and customer what the sum purchases were regardless of category (because you're going for some category percentage or something), then the measure would simply be the following, which you can easily reuse in other measures:
Measure = CALCULATE(SUM('Table'[Purchases]),ALL('Table'[Category]))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
95 | |
77 | |
65 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |