March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
for each account I need to add up the number of times the current month sales totals is greater than the prior month total for a filtered period on the page
Seems like summarize should do it but I think I have to build a summary table in the measure as the table to use in the summarize statement. Any ideas how to best do this?
Solved! Go to Solution.
Hi @bsheffer
you can try this measure
Measure =
var _currentMonth=CALCULATE(MAX('Table'[activity_month]),ALL('Table'))
var _sales=CALCULATE(MIN('Table'[total_sales_amount]),FILTER(ALLEXCEPT('Table','Table'[merchant_number]),'Table'[activity_month]=_currentMonth))
var _count=IF(_sales=0,0,CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[merchant_number]=MIN('Table'[merchant_number])&&'Table'[activity_month]<_currentMonth&&'Table'[total_sales_amount]<_sales)))
return IF(ISBLANK(_count),0,_count)
result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi @bsheffer
In fact, your solution is not common. A more general approach is to create a table,
I find several models, you can try this way, (This way is more efficient)
https://community.powerbi.com/t5/Desktop/Calendar-Table/m-p/1860460
or if you can share your sample data or sample file without sensitive information, then I can write specified measure for your sample.
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
here is some sample data
merchant_number | total_sales_amount | activity_month |
1 | 150 | 6/1/2021 |
1 | 100 | 5/1/2021 |
1 | 50 | 4/1/2021 |
2 | 50 | 6/1/2021 |
2 | 40 | 5/1/2021 |
2 | 100 | 4/1/2021 |
3 | 100 | 5/1/2021 |
3 | 50 | 4/1/2021 |
4 | 50 | 6/1/2021 |
a measure that uses this data should show the result in a table of merchant_number and months_improved
merchant_number | months_improved |
1 | 2 |
2 | 1 |
3 | 0 |
4 | 0 |
6/1/2021 is the current month. Merchant 3 should have a value of 0 because it doesn't have activity in the current month. Merchant 4 should have 0 because it only has 1 month of activity.
Hi @bsheffer
you can try this measure
Measure =
var _currentMonth=CALCULATE(MAX('Table'[activity_month]),ALL('Table'))
var _sales=CALCULATE(MIN('Table'[total_sales_amount]),FILTER(ALLEXCEPT('Table','Table'[merchant_number]),'Table'[activity_month]=_currentMonth))
var _count=IF(_sales=0,0,CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[merchant_number]=MIN('Table'[merchant_number])&&'Table'[activity_month]<_currentMonth&&'Table'[total_sales_amount]<_sales)))
return IF(ISBLANK(_count),0,_count)
result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
I was able to complete it by brute force but I think there has to be a more elegant solution. Here is the code I wrote. I tested back 8 months but really the maximum number of months improved has been 4
Hi @bsheffer
this requirement seems to be possible without building a summary table. But for details, I need to look at your sample data. could you share your sample data or sample file after removing sensitive data?
Any question, please let me know. looking forward to receiving your reply.
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |