Forum Discussion
Anonymous
6 years agoNot 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
- az38
Community Champion
Anonymous
use rankx like
Column = RANKX( FILTER( 'Table', 'Table'[CommitteeName]=EARLIER('Table'[CommitteeName]) && 'Table'[AllotmentMainID]=EARLIER('Table'[AllotmentMainID]) ), 'Table'[ApprovedTotalLimit], , DESC )- sqldev2017
Microsoft Employee
I think DAX is utter nonsense, compared to the simplicity of SQL !
- AnonymousNot applicable
Thank you for your answer but I I could not tell sorry.
For Example :
CommitteeName AllotmentMainID ApprovedTotalLimit A 100 2500 A 100 2500 A 100 3000 B 200 5000 C 300 10000 C 300 5000 Result :
CommitteeName AllotmentMainID ApprovedTotalLimit RowNumber A 100 3000 1 A 100 2500 2 A 100 2500 3 B 200 5000 1 C 300 10000 1 C 300 5000 2 I want to this.
Thank U:)
- az38
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 )