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
ReikoK
Helper I
Helper I

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
ReikoK
Helper I
Helper I

More ideas? 

v-xuxinyi-msft
Community Support
Community Support

Hi @ReikoK 

 

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.

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 @ReikoK ,

 

mahenkj2_0-1713443378434.png

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

 

Hope it helps.

Helpful resources

Announcements
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.

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.