Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ksrini
Helper I
Helper I

Ranking unique values by giving same rank to all duplicates

Hi,

 

I have to rank/index unique values in column which has year-week combination which goes like 2015-01, 2015-02..... 2015-52, 2016-01...to say 2020-30. Per each week, there are several entries, so i need to assign same rank irrespective of the number of duplicates. I tried RankEQ but i could not get it. Can you please suggest any ideas ? 

 

Thanks,

Srinivas

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ksrini ,

 

You may try to use RANKX function. Since you have a year-week combination, there may be a column for the number of weeks and a column for the number of years. I will use these two columns for sorting. If not, it doesn't matter, you can follow the steps below.

 

1.I have a dataset which has the Date column and the Sales column. Create calculated columns as follows to get year-week combination.

 

WEEKNUMBER = WEEKNUM([Date],2)
YEAR = YEAR([Date])
YEARWKKE = [YEAR]&"-"&[WEEKNUMBER]

 

 

 

1.png

 

2.Now create other calculated columns to get ranking.

 

RANKYEAR = RANKX(ALL('Table'),[YEAR],,ASC,Dense)
RANKWEEK = RANKX(ALL('Table'),[WEEKNUMBER],,ASC,Dense)
RANKXYEAR&WEEK = RANKX ( ALL ( 'Table' ), [RANKWEEK] + [RANKYEAR] * 100,, ASC, DENSE )

 

 

 

2.png

 

You can check more details from here.

 

 

 

Best Regards,
Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @ksrini ,

 

You may try to use RANKX function. Since you have a year-week combination, there may be a column for the number of weeks and a column for the number of years. I will use these two columns for sorting. If not, it doesn't matter, you can follow the steps below.

 

1.I have a dataset which has the Date column and the Sales column. Create calculated columns as follows to get year-week combination.

 

WEEKNUMBER = WEEKNUM([Date],2)
YEAR = YEAR([Date])
YEARWKKE = [YEAR]&"-"&[WEEKNUMBER]

 

 

 

1.png

 

2.Now create other calculated columns to get ranking.

 

RANKYEAR = RANKX(ALL('Table'),[YEAR],,ASC,Dense)
RANKWEEK = RANKX(ALL('Table'),[WEEKNUMBER],,ASC,Dense)
RANKXYEAR&WEEK = RANKX ( ALL ( 'Table' ), [RANKWEEK] + [RANKYEAR] * 100,, ASC, DENSE )

 

 

 

2.png

 

You can check more details from here.

 

 

 

Best Regards,
Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Brilliant solution @Anonymous. Really appreciate for the details and the example. It worked perfectly across all duplicates. I did try Rankx earlier itself but we need to standardize the two fields Year, Weeknum to get correct rank. Thanks for your help.

 

Regards,

Srinivas

Anonymous
Not applicable

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors