Forum Discussion
Running Count in DAX Sorted by Date
Hi everyone,
I’m trying to create a running count in Power BI using DAX, sorted by date and time.
I’ve tried CALCULATE with FILTER, but the results don’t stay consistent after refresh.
Could someone share a reliable formula or approach for cumulative counts by date?
Thanks!
Hi THANUGULA_VASU,
A reliable approach is to use a proper Date/DateTime column and calculate the cumulative count based on the maximum date in the current context.
If you're counting rows -
Running Count = VAR CurrentDateTime = MAX ( 'Table'[DateTime] ) RETURN CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table'[DateTime] ), 'Table'[DateTime] <= CurrentDateTime ) )If you're counting distinct IDs -
Running Count = VAR CurrentDateTime = MAX ( 'Table'[DateTime] ) RETURN CALCULATE ( DISTINCTCOUNT ( 'Table'[ID] ), FILTER ( ALL ( 'Table'[DateTime] ), 'Table'[DateTime] <= CurrentDateTime ) )Ensure your visual is sorted by the actual DateTime column, not a formatted text column.
If you can share a small sample of your data (Date/Time column and what you're counting), a more tailored DAX measure can be provided.
💡 Helpful? Give a Kudos 👍 — keep the community growing
✅ Solved your issue? Mark as Solution ✔️ — help others find it faster
Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer
4 Replies
- Rupa01Solution Sage
Hi THANUGULA_VASU,
A reliable approach is to use a proper Date/DateTime column and calculate the cumulative count based on the maximum date in the current context.
If you're counting rows -
Running Count = VAR CurrentDateTime = MAX ( 'Table'[DateTime] ) RETURN CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table'[DateTime] ), 'Table'[DateTime] <= CurrentDateTime ) )If you're counting distinct IDs -
Running Count = VAR CurrentDateTime = MAX ( 'Table'[DateTime] ) RETURN CALCULATE ( DISTINCTCOUNT ( 'Table'[ID] ), FILTER ( ALL ( 'Table'[DateTime] ), 'Table'[DateTime] <= CurrentDateTime ) )Ensure your visual is sorted by the actual DateTime column, not a formatted text column.
If you can share a small sample of your data (Date/Time column and what you're counting), a more tailored DAX measure can be provided.
💡 Helpful? Give a Kudos 👍 — keep the community growing
✅ Solved your issue? Mark as Solution ✔️ — help others find it faster
Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer - ryan_mayuSuper User
could you pls provide some sample data and expected output?
- v-aatheequeCommunity Support
Hi THANUGULA_VASU
Just checking in could you please share the requested sample data and expected output? Once we have that, we'll be happy to investigate further.- v-aatheequeCommunity Support
We wanted to follow up to check if you’ve had an opportunity to review the previous responses. If you require further assistance, please don’t hesitate to let us know.