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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Row Number in DAX

Hi,

My SQL query is this ;

 

SELECT 

            CommitteeName,
            AllotmentMainID,
            ApprovedTotalLimit,

            ROW_NUMBER() OVER(PARTITION BY CommitteeName,AllotmentMainID ORDER BY ApprovedTotalLimit DESC) AS RN

FROM Allotment;

 

I want to write in Dax. How to write Row Number in Dax?

 

Please Help.

Thanx 🙂

 

 

 

5 REPLIES 5
az38
Community Champion
Community Champion

@Anonymous 

use rankx like

Column = 
    RANKX(
        FILTER(
                'Table',
                'Table'[CommitteeName]=EARLIER('Table'[CommitteeName]) &&  'Table'[AllotmentMainID]=EARLIER('Table'[AllotmentMainID])
                ),
        'Table'[ApprovedTotalLimit], , DESC
        )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

I think DAX is utter nonsense, compared to the simplicity of SQL ! 

Anonymous
Not applicable

Thank you for your answer but I I could not tell sorry.

For Example : 

 

CommitteeNameAllotmentMainIDApprovedTotalLimit 
A1002500 
A1002500 
A1003000 
B2005000 
C30010000 
C3005000 

 

Result : 

CommitteeNameAllotmentMainIDApprovedTotalLimitRowNumber
A10030001
A10025002
A10025003
B20050001
C300100001
C30050002

 

I want to this.

 

Thank U:)

az38
Community Champion
Community Champion

@Anonymous 

how do you want to break a tie-situations?

 

you can add an Index column in powe query and the create a dax rankx calculated column

Column = 
    RANKX(
        FILTER(
                'Table',
                'Table'[CommitteeName]=EARLIER('Table'[CommitteeName]) &&  'Table'[AllotmentMainID]=EARLIER('Table'[AllotmentMainID])
                ),
        'Table'[ApprovedTotalLimit] + [Index]/1000000, , DESC, Skip
        )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors