Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
AnSc93
Helper I
Helper I

X-Axis with two levels - Sorting should be different

Hi together,

 

I have a column chart and two levels on the X-Axis.

 

The Axis aren't concatenated and both levels are always shown.

 

Is it possible, to sort one axis by the value and the other one based on ABC for example?

 

I can only find a solution which works either the one or the other way.

Thank you and regards,

Andreas

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

One approach is to create a measure that generates a sort value that considers both the outer and inner dimensions in your visual. You then put the measure in the tooltips area of your visual, click on the ellipsis and sort by it. This example determines the total value at the outer dimension level and does the overall sort; the inner dimension is then sorted reverse alphabetically by name (but you could also use the measure value too).

 

ppm1_0-1680264453549.png

NewSort =
VAR thisQty = [Total Qty]
VAR thisouter =
    SELECTEDVALUE ( Stores[City] )
VAR thisinner =
    SELECTEDVALUE ( Products[Subcategory] )
VAR outerrank =
    RANKX (
        ALLSELECTED ( Stores[City] ),
        CALCULATE ( [Total Qty], REMOVEFILTERS ( Products[Subcategory] ) )
    )
VAR innerrank =
    RANKX ( ALLSELECTED ( Stores[City] ), Stores[City], thisinner )
RETURN
    IF ( NOT ( ISBLANK ( thisQty ) ), 100 * outerrank + innerrank )

 

Pat

 

Microsoft Employee

View solution in original post

1 REPLY 1
ppm1
Solution Sage
Solution Sage

One approach is to create a measure that generates a sort value that considers both the outer and inner dimensions in your visual. You then put the measure in the tooltips area of your visual, click on the ellipsis and sort by it. This example determines the total value at the outer dimension level and does the overall sort; the inner dimension is then sorted reverse alphabetically by name (but you could also use the measure value too).

 

ppm1_0-1680264453549.png

NewSort =
VAR thisQty = [Total Qty]
VAR thisouter =
    SELECTEDVALUE ( Stores[City] )
VAR thisinner =
    SELECTEDVALUE ( Products[Subcategory] )
VAR outerrank =
    RANKX (
        ALLSELECTED ( Stores[City] ),
        CALCULATE ( [Total Qty], REMOVEFILTERS ( Products[Subcategory] ) )
    )
VAR innerrank =
    RANKX ( ALLSELECTED ( Stores[City] ), Stores[City], thisinner )
RETURN
    IF ( NOT ( ISBLANK ( thisQty ) ), 100 * outerrank + innerrank )

 

Pat

 

Microsoft Employee

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.