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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ChocoGanache
Frequent Visitor

Wrong ranking in month granularity

I've been trying to display dynamic TopN projects ranking by Yearly Plan Amount and this little bug has been bothering me. When I choose top3, I expect both Project P2 and P9 to be displayed as they're tie for 3rd place but only P9 shows up in the graphical chart. 

 

I tried pulling all the numbers out in matrix and find that at year granularity, the ranking is correct. Both P2 and P9 are at rank 3. However, at month granularity, P2 drops to rank 5. I don't understand why that happens as when I concat all the values supposedly used for ranking, they're the same at both granularity levels. (as seen in the pic below)

 

ChocoGanache_0-1654849997518.png

 

When I choose Top5, everything is correct and we see that P2 has the exact same Yearly Plan Amount as P9, which is 0.11.

 

ChocoGanache_2-1654850509247.png

 

I've been going at this for days so any help would be much appreciated.

Here's the pbix. 

https://www.dropbox.com/s/grjw80y52o0kaid/Wrong%20ranking%20in%20month%20granularity.pbix?dl=0

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @ChocoGanache 
Here is your sample file with the solution https://we.tl/t-CgcPX7WJq9

1.png2.png

Plan Yearly Amount = 
CALCULATE (
    SUM ( Plan[Amount] ),
    REMOVEFILTERS ( ),
    VALUES ( Project[Project] )
)
Ranking = 
RANKX (
    ALLSELECTED ( Project[Project] ),
    [Plan Yearly Amount]
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

@ChocoGanache 

This is a big question. Need more expert people. @AlbertoFerrari 

tamerj1
Super User
Super User

Hi @ChocoGanache 
Here is your sample file with the solution https://we.tl/t-CgcPX7WJq9

1.png2.png

Plan Yearly Amount = 
CALCULATE (
    SUM ( Plan[Amount] ),
    REMOVEFILTERS ( ),
    VALUES ( Project[Project] )
)
Ranking = 
RANKX (
    ALLSELECTED ( Project[Project] ),
    [Plan Yearly Amount]
)

Thank you so much! It really does work! Unfortunately, when I applied your measure to my actual report (which have more tables and slicers), they do not work. 

Can you explain to me what I did wrong? I still don't understand why your code works and mine doesn't.

 

1. Isn't CALCULATE(SUM(.....), xxx, yyy) calculate the same way whether you put it in a measure (like Plan Yearly Amount in this case) or  type it plainly like in my initial Ranking code? 

 

2. how come for Plan Yearly Amount, REMOVEFILTERS('DATE'[Month Number]) doesn't work? 

 

3. How should I go about debugging my actual report? Pulling numbers into matrix doesn't provide any insight to where the problem is.

 

Thank you so much T-T

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.