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 are following up to see if your query has been resolved. Should you have identified a solution, we kindly request you to share it with the community to assist others facing similar issues.
If our response was helpful, please mark it as the accepted solution and provide kudos, as this helps the broader community.
Thank you.