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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Nun
Resolver I
Resolver I

Rank DAX formula

Hello,

 

I have a table, created with 

ADDCOLUMNS(SUMMARIZECOLUMNS(Sales[Time Code],Sales[Custmer]),"Total Sales",[amountEUR]).
Time code field is linked to a calendar table where there is the same field Time code (each time code is a date)
The result is
Time Code Customer Total Sales 
3262715312,92
6562712334,53
72376511182,11
98376511115,84
2762711004,35
866279992,141
27659637,937
666279196,524
84297751,839
48657737,647
23257304,194
26747213,433

I would need to create a rank of the customer. Same customer has the same rank based on the total sales of all the time.

Thanks.

1 ACCEPTED SOLUTION
timalbers
Advocate V
Advocate V

Hi @Nun 

you can achieve this by adding a calculated column to your table using the following DAX:

rank = 
    RANKX( 
        ALL( table_name ), 
        CALCULATE( 
            SUM( table_name[Total Sales] ), 
            ALL( table_name ), 
            table_name[Customer] = EARLIER( table_name[Customer] ) 
        ), 
        , , DENSE
    )

Please be aware of replacing "table_name" with the actual name of your table.

 

If this answer helped you, please consider marking it as solution.

Thank you!

Cheers

Tim

View solution in original post

1 REPLY 1
timalbers
Advocate V
Advocate V

Hi @Nun 

you can achieve this by adding a calculated column to your table using the following DAX:

rank = 
    RANKX( 
        ALL( table_name ), 
        CALCULATE( 
            SUM( table_name[Total Sales] ), 
            ALL( table_name ), 
            table_name[Customer] = EARLIER( table_name[Customer] ) 
        ), 
        , , DENSE
    )

Please be aware of replacing "table_name" with the actual name of your table.

 

If this answer helped you, please consider marking it as solution.

Thank you!

Cheers

Tim

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Fabric Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.