Forum Discussion
Dax Running Totals Help
Hello,
I am fairly new to DAX..
I have the table below...
It is basically a table of Company statuses. It has a start date when the status was set, and a end date when a status was changed. Once changed a new row gets entered with the new status.
I want to be able to get a running total of by day split by status, but when their is an end subtract from the old status, and add to the new status. It's been driving me up the wall. Anyone got any ideas?
Hi Anonymous ,
Please create a Calendar table.
Calendar = CALENDAR ( DATE ( 2022, 1, 1 ), DATE ( 2022, 12, 31 ) )Then create measure.
CountCompany = CALCULATE ( DISTINCTCOUNT ( 'Table'[CompanyName] ), FILTER ( 'Table', 'Table'[Start_Date] <= MAX ( 'Calendar'[Date] ) && ( 'Table'[END_DATE] >= MAX ( 'Calendar'[Date] ) || 'Table'[END_DATE] = BLANK () ) ) )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- tamerj1
Community Champion
Hi Anonymous
can you provide some sample data?
- tamerj1
Community Champion
Anonymous
you might find the solutions provided in this post helpful https://community.powerbi.com/t5/DAX-Commands-and-Tips/Count-Open-Orders-with-missing-date-records/m-p/2500258#M69112
- v-kkf-msft
Community Support
Hi Anonymous ,
Please create a Calendar table.
Calendar = CALENDAR ( DATE ( 2022, 1, 1 ), DATE ( 2022, 12, 31 ) )Then create measure.
CountCompany = CALCULATE ( DISTINCTCOUNT ( 'Table'[CompanyName] ), FILTER ( 'Table', 'Table'[Start_Date] <= MAX ( 'Calendar'[Date] ) && ( 'Table'[END_DATE] >= MAX ( 'Calendar'[Date] ) || 'Table'[END_DATE] = BLANK () ) ) )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Hello,
Yes i used parts of your Measure, and it worked as intended.
Thank you for the help.
Thanks
Chris