Forum Discussion
Need to swap sorting dimension based on filter selection
- 1 year ago
Hi Raveeshlokanath - Power BI visuals don't directly support sorting by multiple columns conditionally based on slicer input.
Create a disconnected table (let’s call it SortSelection) with two values: Dimension A and Dimension B.
SortSelection =
DATATABLE(
"SortOption", STRING,
{
{"Dimension A"},
{"Dimension B"}
}
)Create a measure to dynamically calculate the sort value based on the slicer selection
DynamicSortValue =
VAR SelectedSort = SELECTEDVALUE(SortSelection[SortOption], "Dimension A")
RETURN
SWITCH(
SelectedSort,
"Dimension A", MAX('YourTable'[DimensionA]),
"Dimension B", MAX('YourTable'[DimensionB]),
BLANK()
)Apply the Sorting Measure in Your Visual:
Add your DynamicSortValue measure to your visual.
Sort the visual by DynamicSortValue.Try the above approach. please check.
Hi All,
Thanks for your inputs, But my requirement is based on filter condition, i.e single select if made on slcier then I should use dimension A to sort else dimension B. How can I switch using dax.