This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
I am having some trouble writing a measure which would count the number of times a status has changed for a particular item. My source is an SDC Type 2 table containing all history of status changes.
I want to make a measure that ranks the count of status changes over time. In the sample data, the grouping is by Fruit, _Timestamp, _Operation, Consumable Status, and Status Change Date. I want to make a column called "Status Change Count" with the below output.
Could anyone help me out with the DAX to accomplish this? Thank you in advance for your help.
Attached is my sample data.
Fruit_Timestamp_OperationConsumable StatusStatus Change Date
|
Solved! Go to Solution.
@cinderelly678 Try:
Measure =
VAR __Fruit = MAX('Table'[Fruit])
VAR __TS = MAX('Table'[Timestamp])
VAR __Table = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table'), [Fruit] = __Fruit && [Timestamp] <= __TS), "__Status", [Consumable Status]))
VAR __Result = COUNTROWS(__Table)
RETURN
__Result
@Greg_Deckler , thank you very much, that worked like a charm!
Now I have a secondary question. Let's say I wanted to iterate over the results of the Measure to flag when the measure has incremented by one over the previous value. How could I achieve that?
@cinderelly678 That's Cthulhu. Cthulhu - Microsoft Fabric Community
Oh goodness -- sweet post! Let me try to wrap my head around this.
I'll likely respond with questions soon.
Thank you so much for sharing @Greg_Deckler !
@cinderelly678 Try:
Measure =
VAR __Fruit = MAX('Table'[Fruit])
VAR __TS = MAX('Table'[Timestamp])
VAR __Table = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table'), [Fruit] = __Fruit && [Timestamp] <= __TS), "__Status", [Consumable Status]))
VAR __Result = COUNTROWS(__Table)
RETURN
__Result
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 25 | |
| 23 | |
| 19 | |
| 17 | |
| 14 |
| User | Count |
|---|---|
| 25 | |
| 23 | |
| 20 | |
| 20 | |
| 19 |