Forum Discussion
Running Total with categories
The issue you’re facing with your cumulative power measure when adding a legend (such as "Geo" or "Status") is likely due to how the DAX formula interacts with the context of the visualization. When you add a legend, it creates additional filtering contexts that affect the calculation, so it’s essential to modify the formula to account for these contexts properly.
Here's a solution you can try by modifying the `RunningTotal` measure to take into account the legend (e.g., "Geo" or "Status"):
### Running Total with Categories Solution:
```DAX
RunningTotal =
VAR CurrentGeo = MAX('Data'[Geo]) -- or MAX('Data'[Status]) if using Status as the category
VAR CurrentYear = MAX('Data'[Op_Year])
RETURN
CALCULATE(
SUM('Data'[Power]),
FILTER(
ALLSELECTED('Data'),
'Data'[Op_Year] <= CurrentYear
&& 'Data'[Geo] = CurrentGeo -- or 'Data'[Status] = CurrentStatus] for Status
)
)
```
### Explanation:
1. **`CurrentGeo` and `CurrentYear`**: These variables capture the current category and year that the chart is focusing on, based on the selected data points.
2. **Filtering with Context**: The `FILTER` function now includes both the year and the `Geo` (or `Status`), ensuring that the cumulative total is calculated only for the current category being plotted.
3. **ALLSELECTED**: This function ensures that the running total respects the selections made in the report (e.g., if you have other slicers affecting the data).
### Notes:
- If you're using `Status` as the legend instead of `Geo`, replace `Geo` with `Status` in the formula.
- You can use this formula for both charts with different legends (one for `Geo` and one for `Status`) by adapting the variable `CurrentGeo` to the relevant column.
This should allow you to properly display the running totals for each category (either by "Geo" or "Status") in the chart without affecting the totals or changing values unexpectedly.
Thanks for the explanation!
I have the issue that if there is no a category on the last period it does not show me from the previous period. So mark A from grade 2 is not showen on the grade 3. Is it possible to solve it somehow?