cancel
Showing results for 
Search instead for 
Did you mean: 
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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors