Forum Discussion
Trend Sorting
- 1 year ago
Create Measures: Ensure that your measure for trend sorting is dynamic and responds to slicer selections. You can use DAX functions like SELECTEDVALUE or ALLSELECTED to capture the slicer values.
Sort Logic: Implement the sorting logic within your measure. For example, you can use SWITCH or IF statements to determine the sorting order based on the trend direction (down arrow first, up arrow last).
Apply Sorting: Use the measure to sort your visual. In Power BI, you can set the sort order of a visual based on a measure.
DAX
TrendSortMeasure =
VAR SelectedSlicer1 = SELECTEDVALUE(SlicerTable1[Column1])
VAR SelectedSlicer2 = SELECTEDVALUE(SlicerTable2[Column2])
-- Add more slicer variables as needed
VAR TrendDirection = IF([TrendMeasure] < 0, 1, 2) -- 1 for down arrow, 2 for up arrow
RETURN
TrendDirection +
IF(SelectedSlicer1 = "Value1", 0,
IF(SelectedSlicer1 = "Value2", 10, 20)) +
IF(SelectedSlicer2 = "ValueA", 0,
IF(SelectedSlicer2 = "ValueB", 5, 10))
-- Add more conditions for other slicers
Create Measures: Ensure that your measure for trend sorting is dynamic and responds to slicer selections. You can use DAX functions like SELECTEDVALUE or ALLSELECTED to capture the slicer values.
Sort Logic: Implement the sorting logic within your measure. For example, you can use SWITCH or IF statements to determine the sorting order based on the trend direction (down arrow first, up arrow last).
Apply Sorting: Use the measure to sort your visual. In Power BI, you can set the sort order of a visual based on a measure.
DAX
TrendSortMeasure =
VAR SelectedSlicer1 = SELECTEDVALUE(SlicerTable1[Column1])
VAR SelectedSlicer2 = SELECTEDVALUE(SlicerTable2[Column2])
-- Add more slicer variables as needed
VAR TrendDirection = IF([TrendMeasure] < 0, 1, 2) -- 1 for down arrow, 2 for up arrow
RETURN
TrendDirection +
IF(SelectedSlicer1 = "Value1", 0,
IF(SelectedSlicer1 = "Value2", 10, 20)) +
IF(SelectedSlicer2 = "ValueA", 0,
IF(SelectedSlicer2 = "ValueB", 5, 10))
-- Add more conditions for other slicers