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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Sort X-axis by 2 dimensions

Hi!

 

I have two dimensions ("main brands" and year") in X-axis and I would like to sort car brands by last year investments in descending order leaving the previous years investments under the same car brand. "OTHER" value have to be at the end of the list in the graph.

 

How it looks at the moment : 

ReikoK_1-1713440579076.png

Example, how sorting should look like:

ReikoK_2-1713440680772.png

 

 

From the forum I found that kind of formula but I am not sure if it could work on my desired outcome: 

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 )

 

Sample PBix and data: https://we.tl/t-1Y2odt9GvQ

 

Thanks in advance!

4 REPLIES 4
Anonymous
Not applicable

More ideas? 

Anonymous
Not applicable

Hi @Anonymous 

 

Thanks for the reply from @mahenkj2 , please allow me to provide another insight:

 

I extracted a portion of your data and did the following test. I hope it helps.

vxuxinyimsft_0-1713509216017.png

 

I enter a new table called the order table, which serves to give the Main brands columns the order you want them to be in.

vxuxinyimsft_2-1713509556714.png

 

Then merge the two tables together

vxuxinyimsft_3-1713509584557.png

 

vxuxinyimsft_4-1713509614557.png

 

Expand the table to preserve the order column

vxuxinyimsft_5-1713509647366.png

 

Because Main brands is a calculated column, and calculated columns cannot be loaded into Power Query, I only gave the order table 12 rows, and the Brand belonging to the OTHERS with an order column of null, replacing the null value with 13.

vxuxinyimsft_8-1713510087902.png

 

vxuxinyimsft_6-1713509683654.png

Select the Main brands column to sort by the order column.

vxuxinyimsft_7-1713509764832.png

 

Result:

vxuxinyimsft_9-1713510137640.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks for you help but I need it to be dynamical. That solution outcome is what I need, but once I am going to change years and months, brands are not sorted by last year investments in DESC order

mahenkj2
Solution Sage
Solution Sage

 Hi @Anonymous ,

 

mahenkj2_0-1713443378434.png

Use clustred column chart and use year as legend. Experiment as per your need.

 

Hope it helps.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors