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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
sqldev2017
Microsoft Employee
Microsoft Employee

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

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors