Forum Discussion
THANUGULA_VASU
2 months agoRegular Visitor
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 someo...
- 2 months ago
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_mayu
Super User
2 months agocould you pls provide some sample data and expected output?