Forum Discussion
Running Total Cohort DAX
- Anonymous5 years ago
Hi 1katznir
I think you want to calculate the running total for each Start_OF_Month_Date by Cohort_Month.
And compare the expense with measure to calculate the min Cohort_Month for each Start_OF_Month.
I build two measures:
Running Total Booking Amount = SUMX ( FILTER ( ALL ( BOOKING_MONTHLY_COHORT ), BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] = MAX ( BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] ) && BOOKING_MONTHLY_COHORT[Cohort_Month] <= MAX ( BOOKING_MONTHLY_COHORT[Cohort_Month] ) ), BOOKING_MONTHLY_COHORT[Booking_Amount] )M.Cohort_Month = VAR _RunningTotalExpense_Amount = SUMX ( FILTER ( ALL ( BOOKING_MONTHLY_COHORT ), BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] = MAX ( BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] ) && BOOKING_MONTHLY_COHORT[Cohort_Month] <= MAX ( BOOKING_MONTHLY_COHORT[Cohort_Month] ) ), BOOKING_MONTHLY_COHORT[Expense_Amount] ) VAR _COHORT = MINX ( FILTER ( ALL ( BOOKING_MONTHLY_COHORT ), BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] = MAX ( BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] ) && [Running Total Booking Amount] >= _RunningTotalExpense_Amount ), BOOKING_MONTHLY_COHORT[Cohort_Month] ) RETURN IF(NOT(ISBLANK(_COHORT)),IF(MAX(BOOKING_MONTHLY_COHORT[Cohort_Month])=_COHORT,_COHORT,BLANK()),BLANK())Result is as below.
You can download the pbix file from this link: Running Total Cohort DAX
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Here is a sample of the data structure, note:
- Additional columns exists that provide further breakdowns as described above
Hi 1katznir
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and the result you want or share me with your pbix file from your Onedrive for Business.
Best Regards,
Rico Zhou