Forum Discussion
Dynamic DAX Variable
- 1 year ago
Hi fergu513,
Thank you for the update.
Please follow the steps outlined below, which may assist in resolving the issue:
-
DAX cannot track the order of slicer selections; therefore, the best approach is to control behavior based on drill level visibility using ISINSCOPE():
VAR TotalGMPY =
SWITCH(
TRUE(),
ISINSCOPE(GPH[GPH Level2]), CALCULATE([TotalGM PY], REMOVEFILTERS(GPH[GPH Level1])),
ISINSCOPE(GPH[GPH Level1]), CALCULATE([TotalGM PY], REMOVEFILTERS(PS_TYPE[PS_TYPE])),
ISINSCOPE(PS_TYPE[PS_TYPE]), CALCULATE([TotalGM PY], REMOVEFILTERS(Manufacturer[VENDOR_NAME])),
CALCULATE([TotalGM PY])
)
This measure makes the calculation responsive to the matrix drill level, even when multiple slicer values are selected. -
The SELECTEDVALUE() function returns a blank if multiple values are selected, which causes the SWITCH() function to fall into the default case. We can rectify this by using ISINSCOPE() or VALUES() instead of SELECTEDVALUE() when supporting multi-selections, or by limiting the slicer to single-select.
If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members who face similar queries.
Thank you.
-
Hi fergu513,
We wanted to check in regarding your query, as we have not heard back from you. If you have resolved the issue, sharing the solution with the community would be greatly appreciated and could help others encountering similar challenges.
If you found our response useful, kindly mark it as the accepted solution and provide kudos to guide other members.
Thank you.