cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cdcphist
Frequent Visitor

Ranking in subcategories

Hi,

 

I have the following data:

 

IDCompanyValueRanking in companyTotal Ranking
1A1517
2A5314
3A1229
4B1812
5B4416
6B3618
7B1724
8B4416
9B9312
10B1719
11C9412
12C11210
13C1812
14C5514
15C10311
16D1448
17D2011
18D1636
19D1519
20D1724

 

I know how to create a calculated column for the total ranking (the "Total Ranking" column) but i need to rank these rows with a calculated column inside each company (the "Ranking in company column"). What i tried has mostly resulted in giving the same rank to all the items.

 

Thanks.

2 ACCEPTED SOLUTIONS
selimovd
Community Champion
Community Champion

Hey @cdcphist ,

 

you can filter the table that has to be considered to the current row context company.

Try the following calculated column:

Rank company = 
VAR vRowCompany = myTable[Company]
VAR vFilterTable = FILTER( myTable, myTable[Company] = vRowCompany )
RETURN
    RANKX( vFilterTable, myTable[Value] )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

Jihwan_Kim
Community Champion
Community Champion

Hi, @cdcphist 

I am not sure if I understood your question correctly but please check the below picture and the sample pbix file's link down below.

 

Picture3.png

 

Rank in Each Company CC =
VAR currentcompany = 'Table'[Company]
RETURN
RANKX ( FILTER ( 'Table', 'Table'[Company] = currentcompany ), 'Table'[Value] )

 

https://www.dropbox.com/s/yseko7od474icwa/cdcphist.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

8 REPLIES 8
Simona0926
Microsoft
Microsoft

Hey all,

I tried that measure as well on Area, but i have the error below.

is there something i do wrong?

The Area column indeed is a text one.

 

Simona0926_0-1623598027604.png

 

Simona0926_1-1623598057673.png

 

Hi, @Simona0926 

I am not sure whether you want to create a new measure or a new column.

Share your sample pbix file's link here with how your desired outcome looks like.

Thanks.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

Hi,

 

I want to create a new measure fo the "Cancellation Rate" visual.

When I choose the status "cancelled" for example i need to see the rate of the status calculated for each Area (actually i need something similar to the table calculation " % of Row total"). 

 

You have here the link to the PBI as well.

Sample - Power BI

 

Simona0926_0-1623665679336.png

 

Hi, @Simona0926 

Sorry that I cannot understand what is the relationship between the initial question of this post and your question.

 

Anyway, I cannot open your link. I think it is linked to the power bi service, not the file.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

Jihwan_Kim
Community Champion
Community Champion

Hi, @cdcphist 

I am not sure if I understood your question correctly but please check the below picture and the sample pbix file's link down below.

 

Picture3.png

 

Rank in Each Company CC =
VAR currentcompany = 'Table'[Company]
RETURN
RANKX ( FILTER ( 'Table', 'Table'[Company] = currentcompany ), 'Table'[Value] )

 

https://www.dropbox.com/s/yseko7od474icwa/cdcphist.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

selimovd
Community Champion
Community Champion

Hey @cdcphist ,

 

you can filter the table that has to be considered to the current row context company.

Try the following calculated column:

Rank company = 
VAR vRowCompany = myTable[Company]
VAR vFilterTable = FILTER( myTable, myTable[Company] = vRowCompany )
RETURN
    RANKX( vFilterTable, myTable[Value] )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

I need Top N Locations based on their sum of scores and ordered by the sum of Total Loss amount, and want to the locations to be ranked for the records where their sum of Toptal Loss amount is not blank, I am able to get the ranked locations based on sum of Total Loss amount but not able to get their sum of scores(of Ranked locations), I am getting al the locations, please help.

Measure =
var RankingDimension = values('Table'[Location name])
Var
RankingSelect = selectedvalue('Top N RG'[Top N RG])
var ranking2 = if(isblank(calculate(sum('Table'[Total Loss]))), blank(),
rankx(filter(All('Table'[Location name]), not(isblank(calculate(sum('Table'[Total Loss]))))),
calculate(sum('Table'[Total Loss])),, desc,skip))
return
ranking2

Works great. Thank you.

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors