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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
abbaig63
New Member

Calculate the sum of rankx values within a category, across all categories

Hello,

 

I am trying to rank a list of stores by sales on a period by period basis. For example, this is what a desired table would look like:

PeriodStoreSalesRank
1A1002
1B1501
1C753
2A1103
2B1202
2C1351

 

Then I would like have the sum of the ranks for each store like so:

StoreSum of Rank
A5
B3
C4

 

I am able to calculate the ranks in the first table using the following measure:

Rank = 

    RANKX(

        FILTER(

            ALL(Table[Period], Table[Store])

            Table[Period] = MAX(Table[Period])

        ),

        CALCULATE(SUM(Table[Sales])

    )
 
However, this requires the period being included, which I do not need, since I only care about the final sum.
How can I apply this measure across all periods independently?
 
Thank you
 
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure what is your desired outcome, but I tried to create it by using measures.

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_0-1684811728425.png

 

Jihwan_Kim_1-1684812271405.png

 

 

Expected result measure: =
VAR _rank =
    ADDCOLUMNS (
        VALUES ( Period[Period] ),
        "@rank",
            RANK (
                SKIP,
                SUMMARIZE ( ALL ( Data ), Store[Store], Period[Period] ),
                ORDERBY ( CALCULATE ( SUM ( Data[Sales] ) ), DESC ),
                PARTITIONBY ( Period[Period] )
            )
    )
RETURN
    SUMX ( _rank, [@rank] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure what is your desired outcome, but I tried to create it by using measures.

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_0-1684811728425.png

 

Jihwan_Kim_1-1684812271405.png

 

 

Expected result measure: =
VAR _rank =
    ADDCOLUMNS (
        VALUES ( Period[Period] ),
        "@rank",
            RANK (
                SKIP,
                SUMMARIZE ( ALL ( Data ), Store[Store], Period[Period] ),
                ORDERBY ( CALCULATE ( SUM ( Data[Sales] ) ), DESC ),
                PARTITIONBY ( Period[Period] )
            )
    )
RETURN
    SUMX ( _rank, [@rank] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

This works perfectly, thank you!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.