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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Ranking a value within a table to other values in the same column differentiated by year and account

Hi All, I am having trouble with the RANKX created measure in Power BI. This is what I currently have:

           Rank = RANKX( Filter( All(
           Query1[Year], Query1[Account Name]),
           Query1[Year] = MAX(Query1[Year])),
           CALCULATE(SUM(Query1[Value]
           )))
 

But based on previous knowledge of the dataset, I know it is not ranking the values correctly. It is spitting out a number that is larger than the amount of data points in the spreadsheet. I included the table below that is named Query1 in my PowerBI file. My goal is to rank the column 'Value' for each account within all values in that column for each year separately. Then, if possible, rank within each year by state. I welcome any and all help. Thank you! 

 

YearAccount NameStateValue
2016ABC Co.New York80
2017ABC Co.New York70
2018ABC Co.New York60
20161234 CompanyPennsylvania77
20171234 CompanyPennsylvania68
20181234 CompanyPennsylvania42
2016Test AccountNew York58
2017Test AccountNew York91
2018Test AccountNew York37
2016XYZ, Inc.Maine77
2017XYZ, Inc.Maine93
2018XYZ, Inc.Maine18
1 REPLY 1
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

 

not quite sure what you are after. If you are looking to create calculated columns, try these two codes:

RankAccountByYears =
RANKX (
    CALCULATETABLE ( 'Table'; ALLEXCEPT ( 'Table'; 'Table'[Year] ) );
    'Table'[Value]
)

 

RankAccountByYearsAndState =
RANKX (
    CALCULATETABLE ( 'Table'; ALLEXCEPT ( 'Table'; 'Table'[Year]; 'Table'[State] ) );
    'Table'[Value]
)


 Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors