Forum Discussion
dax issue
Hi Anonymous
You're trying to simulate variations of a measure called [Cost] by generating a table with a ±5 step range in 5% increments. The Simulated Cost Table you wrote uses GENERATESERIES(-5, 5, 1) to produce steps from -5 to +5, and for each step, it calculates a simulated cost by applying that percentage shift to the base [Cost]. However, the issue you're facing is that the [Cost] measure isn't responding to the date filters applied in your report. This happens because when you assign VAR BaseCost = [Cost] outside of the ADDCOLUMNS() row context, it gets evaluated once in the context of the overall visual or page, without considering each row's filter context—especially the current date selection.
To fix this, you should move the calculation of [Cost] inside the row context of ADDCOLUMNS by wrapping it in a CALCULATE function so that it's dynamically recalculated for each row based on the current report filters, including dates. Here's how you can modify it:
Simulated Cost Table =
ADDCOLUMNS(
GENERATESERIES(-5, 5, 1),
"BaseCost", CALCULATE([Cost]),
"SimulatedCost",
VAR Step = [Value]
RETURN CALCULATE([Cost]) * (1 + Step * 0.05)
)
This version ensures that [Cost] is recalculated within the appropriate filter context for each row, respecting the date and any other filters applied in the report.