The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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-Jan-21 | 1 |
1 | 02-Jan-21 | 2 |
1 | 03-Jan-21 | 3 |
2 | 01-Jan-21 | 1 |
2 | 02-Jan-21 | 2 |
3 | 01-Jan-00 | 1 |
4 | 01-Jan-00 | 1 |
This DAX is not working, I am receiving all 1 values as below:
ID | Date | Rank |
1 | 01-Jan-21 | 1 |
1 | 01-Jan-21 | 1 |
1 | 02-Jan-21 | 1 |
1 | 03-Jan-21 | 1 |
2 | 01-Jan-21 | 1 |
2 | 02-Jan-21 | 1 |
3 | 01-Jan-00 | 1 |
4 | 01-Jan-00 | 1 |
Solved! Go to Solution.
The newer RANK function should make this easier than it used to be.
Try this:
RANK (
DENSE,
ORDERBY ( 'Table'[Date], ASC ),
PARTITIONBY ( 'Table'[ID] )
)
Calculate column on Table, where you add a column to calculate the year
Year = YEAR ( Tabella[Date] )
Finale Column
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
The newer RANK function should make this easier than it used to be.
Try this:
RANK (
DENSE,
ORDERBY ( 'Table'[Date], ASC ),
PARTITIONBY ( 'Table'[ID] )
)
Thanks mate, perfect.
Hi @Jamesfindog ,
Check this post.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsSame issue, utilised exactly, still receiving all 1 values.
Apologies, I desire this to be ranked by earliest date.
I do not understand the following
1 are yo ulooking for a column to add to the table or to a measure?
2 your desred result is confusing
ID | Date | Rank |
1 | 01-Jan-21 | 1 |
1 | 01-Jan-21 | 1 |
1 | 02-Jan-21 | 2 |
1 | 03-Jan-21 | 3 |
2 | 01-Jan-21 | 1 |
2 | 02-Jan-21 | 2 |
3 | 01-Jan-00 | 1 |
4 | 01-Jan-00 | 1 |
do you want the rank within a year?
Thanks
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
Hi mate,
A new column, which ranks the dates grouped by each ID.
The actual date value is irrelevant, I just want the earliest to be 1 for each ID, and the second 2, and so forth.
Calculate column on Table, where you add a column to calculate the year
Year = YEAR ( Tabella[Date] )
Finale Column
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