cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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 November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors