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!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hi all, I am trying to create a DAX loop that will help me solve the following:
Background:
Pain point:
202011 period-sum all actuals if the PaymentMonth <=23...............................................20229 period-sum all actuals if the PaymentMonth <=1,
@Anonymous
Hi @Mus123 ,
I created some data:
Here are the steps you can follow:
1. Create calculated column.
Flag =
var _dis=DISTINCTCOUNT('Table'[YearMonth])
return
_dis - [PaymentMonth] +1Loop =
var _1=SELECTCOLUMNS(FILTER(ALL('Table'),[YearMonth]=EARLIER('Table'[YearMonth])),"1",[PaymentMonth])
return
SUMX(FILTER(ALL('Table'),
'Table'[Flag] in _1 ),[Value])
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
@Anonymous my data looks like this:
Each year_month has payment_month that runs from 1 to 25.
Thank you.
P/S once the condition is met, I want to sum the actuals. e.g 20209 -sum all actuals if the payment month is <=25,
202010 -sum all actuals if the payment month is <=24 ......etc
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 57 | |
| 53 | |
| 40 | |
| 17 | |
| 16 |
| User | Count |
|---|---|
| 116 | |
| 105 | |
| 41 | |
| 34 | |
| 25 |