The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello All,
I need to swap sorting dimension, based on slicer selection in DAX, i.e in the drop down if single selection is made then need to sort the visual with Dimension A else B.
please let me know your thoughts.
Solved! Go to Solution.
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.
Proud to be a Super User! | |
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.
Hi @Raveeshlokanath ,
If your expected output looks like this:
You could try using field parameters, measure, and visual calculations to implement it.
I have attached a pbix file for your reference.
Using visual calculations in Power BI Desktop - Power BI | Microsoft Learn
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
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.
Hi @Raveeshlokanath ,
Please try the method provided by rajendraongole1, for your ease of understanding I have attached a pbix file for reference.
DynamicSortValue =
VAR SelectedSort =
HASONEVALUE ( 'SortSelection'[SortOption] )
RETURN
IF ( SelectedSort, MAX ( 'Table'[DimensionA] ), MAX ( 'Table'[DimensionB] ) )
Best Regards,
Gao
Community Support Team
Hi @Raveeshlokanath ,
At this time, this is not a viable option.
Bookmarks can be used to save sorted states, which may be a suitable alternative to consider if the number of dimensions is relatively small.
In the meantime, we kindly request that you submit this idea here to assist PowerBI in making improvements.
Welcome to Microsoft Fabric Ideas
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
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.
Proud to be a Super User! | |