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 working with transactional data. I have two years worth of data per account. Each Bill is a row and has a date and a column with zero if the bill is paid or a 1 to say its being unpaid. I would like to find out the last number of bills unpaid in a row. number of rows since last 0 based on the account id.
Thanks
Account ID Bill Date Paid Bill ID
100000001 01-02-2013 1 1
100000001 01-04-2013 0 2
100000001 01-05-2013 1 3
100000001 01-06-2013 1 4
100000001 01-07-2013 1 5
100000002 01-02-2013 0 1
100000002 01-04-2013 1 2
100000002 01-05-2013 0 3
100000002 01-06-2013 1 4
100000002 01-07-2013 1 5
So Account ID 100000002 should be 2 and So Account ID 100000001 should be 3
Solved! Go to Solution.
Hi @Dubfelix
I use your data model to have a test. You can try my measure.
Measure =
VAR _Max0Date = MAXX(FILTER(ALL('Table'),AND('Table'[Account ID]=MAX('Table'[Account ID]),'Table'[Paid] = 0)),'Table'[Bill Date])
VAR _Count = CALCULATE(COUNT('Table'[ID]),FILTER(ALL('Table'),AND('Table'[Account ID]=MAX('Table'[Account ID]),'Table'[Bill Date]>_Max0Date)))
RETURN
_CountCount = SUMX(SUMMARIZE('Table','Table'[Account ID]),[Measure])
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Dubfelix ,based on what I got
a measure is
calculate(count(Table[Account ID]), filter(Table, Table[Paid] =1))
sub total measure
calculate(count(Table[Account ID]), filter(Table, Table[Paid] =1), allexcept(Table, Table[Account ID])
new column
countx(filter(Table, Table[Account ID] = earlier(Table[Account ID]) && Table[Paid] =1 ), [Account ID])
@amitchandak It seems to be doing a full count of all unpaid bills rather then unpaid since the last paid bill.
So Account ID 100000002 should be 2 and So Account ID 100000001 should be 3
I seem to be getting based on your help
Account ID 100000002 getting 3 and So Account ID 100000001 and I getting 4
Hi @Dubfelix
I use your data model to have a test. You can try my measure.
Measure =
VAR _Max0Date = MAXX(FILTER(ALL('Table'),AND('Table'[Account ID]=MAX('Table'[Account ID]),'Table'[Paid] = 0)),'Table'[Bill Date])
VAR _Count = CALCULATE(COUNT('Table'[ID]),FILTER(ALL('Table'),AND('Table'[Account ID]=MAX('Table'[Account ID]),'Table'[Bill Date]>_Max0Date)))
RETURN
_CountCount = SUMX(SUMMARIZE('Table','Table'[Account ID]),[Measure])
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
|---|---|
| 64 | |
| 56 | |
| 43 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 123 | |
| 108 | |
| 44 | |
| 32 | |
| 24 |