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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Jo5hua22
Helper I
Helper I

Compare duplicated data from RANKX with another column

Hi members,

 

I would require your support to compare duplicated data that is obtained via RANKX function

 

I used RANKX to create an index based on another column (Date) using DAX command

 

Now this column has duplicated values. I would like to compare values with another column if there is duplication and then I would like to Rank this column.

 

Example:

Expected calculation:

Step 1: Date has to be sorted in ascending order;
Step 2: Then if the index values are same, they should be sorted according to the ascending order of the machine number

Raw input   
S.NoDateMachine numberCreated Index value
A121201.08.202151
A121307.08.202113
A121401.08.202131
A121506.08.202152
A121608.08.202124
A121701.08.202111
Expected calculation   
A121701.08.202111
A121401.08.202132
A121201.08.202153
A121506.08.202154
A121307.08.202115
A121608.08.202126
1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @Jo5hua22 

Please try formulas as below:

Created Index value = RANKX('Table','Table'[Date],,ASC,Dense)
machine number Ranked = RANKX('Table','Table'[S.No],,DESC,Dense)
Result = 
VAR machine_ranked =
    MAX ( 'Table'[machine number Ranked] ) //Maximum  value of sub-column(machine)=5
VAR result =
    RANKX (
        ALL ( 'Table' ),
        'Table'[Created Index value] * machine_ranked + 'Table'[machine number Ranked],   
        //Rank of the main column * 5+ the rank of the sub-column
        ,
        ASC,
        DENSE
    )
RETURN
    result

44.png

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @Jo5hua22 

Please try formulas as below:

Created Index value = RANKX('Table','Table'[Date],,ASC,Dense)
machine number Ranked = RANKX('Table','Table'[S.No],,DESC,Dense)
Result = 
VAR machine_ranked =
    MAX ( 'Table'[machine number Ranked] ) //Maximum  value of sub-column(machine)=5
VAR result =
    RANKX (
        ALL ( 'Table' ),
        'Table'[Created Index value] * machine_ranked + 'Table'[machine number Ranked],   
        //Rank of the main column * 5+ the rank of the sub-column
        ,
        ASC,
        DENSE
    )
RETURN
    result

44.png

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sevenhills
Super User
Super User

Please post your DAX to know the issue ... (Always, issue, data, code, expected output helps the community to answer)

 

It looks like you are trying to do is SQL's DENSE_RANK. 

 

Check these two articles

https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

 

https://community.powerbi.com/t5/Desktop/Rank-based-on-date-for-each-individual-user/td-p/411053

 

Thanks

Helpful resources

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

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

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.

Users online (2,421)