Forum Discussion
Column Reference From Field Parameter Slicer in DAX
I'm trying to custom rank a selected column from a slicer. Below works with the fully qualified column name.
MeasureBinSort = SWITCH(MAX('Turnaround'[Order Time to Begin Time (bins)]),
"x <= 30", 1,
"30 < x <= 60", 2,
"60 < x <= 90", 3,
"90 < x <= 120", 4,
"120 < x <= 150", 5,
"150 < x <= 180", 6,
"180 < x <= 210", 7,
"210 < x <= 240", 8,
"240 < x <= 270", 9,
"270 < x <= 300", 10,
"300 < x", 11
)
'Turnaround'[Order Time to Begin Time (bins)] exists as a selection in a field parameter slicer found in 'Measure Slicer'[Measure Slicer Fields] in the form of NAMEOF('Turnaround'[Order Time to Begin Time (bins)])
I want to update the above measure to use any selected column from that field parameter slicer. All of the columns that can be selected use the same values seen above, so they should all be ranked the same.
I tried this, and DAX says the MAX function only accepts a column reference as an argument:
MeasureBinSort = SWITCH(MAX(SELECTEDVALUE('Measure Slicer'[Measure Slicer Fields])),
"x <= 30", 1,
"30 < x <= 60", 2,
"60 < x <= 90", 3,
"90 < x <= 120", 4,
"120 < x <= 150", 5,
"150 < x <= 180", 6,
"180 < x <= 210", 7,
"210 < x <= 240", 8,
"240 < x <= 270", 9,
"270 < x <= 300", 10,
"300 < x", 11
)
I feel like I'm close, but just can't cross the finish line. Does anyone have any ideas?
2 Replies
- Gabry
Super User
- AnonymousNot applicable
Thanks for the reply from Gabry.
Hi diablo9083 ,
This error occurs because SELECTEDVALUE returns a single value instead of a column reference, it is recommended that you use the slicer directly.
Here is the test data I created:
In Power Query Editor, unpivot the column:
The result is as follows:
Best Regards,
ZhuIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.