Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 56 | |
| 42 | |
| 41 | |
| 20 | |
| 19 |