Forum Discussion
Resources Exceeded - Running Total on Datediff calculated column
- 2 years ago
I am using import mode, but after lot of struggle I finally managed to do it.
Way I did it, I created new dimension with only month numbers and made relationship between it and datediff, and then calculated running total using newly created dimension.
Step 1: create a calculated column to calculate the difference in months between the Acquisition Date and the Transaction Date:
DateDiffInMonths = DATEDIFF('Revenue'[AcquisitionDate], 'Revenue'[TransactionDate], MONTH)
step2:create a measure for the cumulative revenue. This measure will sum the revenue up to the current month for each cohort:
CumulativeRevenue =
CALCULATE(
SUM('Revenue'[Revenue]),
FILTER(
ALLSELECTED('Revenue'),
'Revenue'[AcquisitionDate] = MAX('Revenue'[AcquisitionDate]) &&
'Revenue'[DateDiffInMonths] <= MAX('Revenue'[DateDiffInMonths])
)
)
step3: To ensure the measure is optimized for performance, consider using variables and avoiding iterative functions where possible:
CumulativeRevenueOptimized =
VAR SelectedAcquisitionDate = MAX('Revenue'[AcquisitionDate])
VAR SelectedMonth = MAX('Revenue'[DateDiffInMonths])
RETURN
CALCULATE(
SUM('Revenue'[Revenue]),
FILTER(
ALLSELECTED('Revenue'),
'Revenue'[AcquisitionDate] = SelectedAcquisitionDate &&
'Revenue'[DateDiffInMonths] <= SelectedMonth
)
)
Step4: Create a Matrix Visual
1. Rows: Place the acquisition cohorts (based on the Acquisition Date) in the Rows.
2. Columns: Use the DateDiffInMonths column to show the month difference in the Columns.
3. Values: Add the CumulativeRevenueOptimized measure to the Values.
By creating the DateDiffInMonths column and using the optimized cumulative measure,
you should be able to generate a visual that shows acquisition cohorts and their cumulative revenue
over time without exceeding resource limits.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.