Forum Discussion
Anonymous
1 year agoNot applicable
RANK with PARTITION BY Like SQL
Hi, I am looking to use a DAX formula, similar to the RANK with Partition By window function within SQL. My desired result is the below: ID Date Rank 1 01-Jan-21 1 1 01-J...
- 1 year ago
The newer RANK function should make this easier than it used to be.
Try this:
RANK ( DENSE, ORDERBY ( 'Table'[Date], ASC ), PARTITIONBY ( 'Table'[ID] ) ) - 1 year ago
Calculate column on Table, where you add a column to calculate the year
Year = YEAR ( Tabella[Date] )
Finale Column
RANK ( DENSE, ORDERBY( Tabella[Date] ), DEFAULT, PARTITIONBY( Tabella[YEAR]))If this helped, please consider giving kudos and mark as a solution
me in replies or I'll lose your threadconsider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
MFelix
1 year agoSuper User
Hi Anonymous ,
Check this post.
Anonymous
1 year agoNot applicable
Same issue, utilised exactly, still receiving all 1 values.
rn =
VAR CurrentDate =
SELECTEDVALUE ( Table[Date] )
VAR RankingTable =
CALCULATETABLE (
SUMMARIZE ( Table, Table[Date] ),
ALLSELECTED (), -- filter context of visual
VALUES ( Table[ID]) -- retain current Category filter
)
RETURN
RANKX (
RankingTable,
Table[Date],
CurrentDate,
ASC
)