Forum Discussion
Measure for running total between two dates
- 6 years ago
I initially solved this with a brute force method in SQL, creating a new table with a row for each account for each month live and running a countrows over this. While this worked and allowed interactivity the table itself was massive and would grow by millions of rows each year.
Have just cracked this using DAX:
1. Add a date table to the model, for this example just the date and month name was needed.
2. Create a active relationship from Live Date to the Date column in the date table
3. Create an inactive relationship from Close Date to the Date column in the date table
4. Add the following measure:
Running Live = VAR RunningPlacedTotal = CALCULATE ( COUNTA ( 'Base Data'[Live Month] ), FILTER ( ALL ( 'Dates Base'[MonthName] ), ISONORAFTER ( 'Dates Base'[MonthName], MAX ( 'Dates Base'[MonthName] ), DESC ) ) ) VAR RunningCloseTotal = CALCULATE ( COUNTA ( 'Base Data'[Close Month] ), USERELATIONSHIP ( 'Base Data'[Close Date], 'Dates Base'[DateID] ), FILTER ( ALL ( 'Dates Base'[MonthName] ), ISONORAFTER ( 'Dates Base'[MonthName], MAX ( 'Dates Base'[MonthName] ), DESC ) ) ) RETURN RunningPlacedTotal - RunningCloseTotal5. Add graph with measure to values, and the date table month to the axis.
6. Add a visual level relative date filter to match your needs.
Hope this helps!
My mistake! Use "Live Month" for your x-axis, and then use count of "Live Month" for your values. This way you are counting the amount of Live Accounts were created in that month. Then place "Close Month" as a visual filter and filter to only show the 2099's, limiting the data to only show live accounts that have not been closed
Hope this works!
Have updated with your suggestion and still cannot get this to work? Again unless I have made a mistake on my end?