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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
AndreaRSMRCT
Frequent Visitor

Ranking

Hello community,

 

I have the following situation:

 

PowerBI_Rank1.PNG

In the "PROGETTO" Table there are different sort of projects, In the "PRODOTTI" Table there are different kind of products related to each project. For example the project "PRO_0001" can have three different kind of products (each product has a € value (Prodotto_Importo Column).

 

In the "PROGETTO" Table there are also a column called "Progetto_Stato" which contains the current status of the project ("On going", "Abandoned", "Finished").

 

I would like to create a rank formula which calcs the rank of each project in terms of values, but only considering those ones that have a status not equal to "Abandoned".

 

 

PowerBI_Rank2.PNG

There are 10 projects, but in the picture you can see just only 6 because PRO_0004 and PRO_0008 are "Abandoned" (I insert "Progetto_Stato" in the "Visual Level Filters". And there aren't PRO_0009 and PRO_0010 because they are related to year 2018 and I want just 2019's once (I selected 2019 in the Year Filter).

 

How can i get the correct rank of these projects? I tried to use this formula but it doesn't work:

 

Importo_Rank =

 

RANKX(ALLSELECTED(PROGETTO[Progetto_Cod]), SUM(PRODOTTI[Prodotto_Importo]),,DESC)

 

With this formula the table shows me even the PRO_0009 and PRO_0010 (Year 2018) and for each project it gives a rank equal to 1.

 

Thanks in advance

 

Andrea

6 REPLIES 6
Mariusz
Community Champion
Community Champion

Hi @AndreaRSMRCT 

Try this.

RANKX(
    CALCULATETABLE(
        VALUES(PROGETTO[Progetto_Cod]),
        ALLSELECTED()
    ), 
    SUM(PRODOTTI[Prodotto_Importo]),,
    DESC
)



Regards,
Mariusz

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

Hello Mariusz,

 

The result is still the same. I post a screenshot:

 

 

PowerBI_Rank3.PNG

 

I don't know why when I use the rank function the selection made on Year filter doesn't work and it shows me even the projects of the 2018.

 

Andrea

Hi @AndreaRSMRCT,

Try the wrapping your SUM in CALCULATE as below or replace the SUM expression with [Prodotto Importo] Measure if you have created one.

 

RANKX(
    CALCULATETABLE(
        VALUES(PROGETTO[Progetto_Cod]),
        ALLSELECTED()
    ), 
    CALCULATE(SUM(PRODOTTI[Prodotto_Importo])),,
    DESC
)

Regards,
Mariusz

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

Now it's working except for the 2018's values:

 

 

PowerBI_Rank4.PNG

Because when I select 2019 from the related filter I would like to see just the projects created in 2019.

 

I thought that ALLSELECTED was able to do it.Smiley Indifferent

 

Andrea

Hi @AndreaRSMRCT 

Try the below.

RANKX(
    CALCULATETABLE(
        VALUES(PRODOTTI[Progetto_Cod]),
        ALLSELECTED()
    ), 
    CALCULATE(SUM(PRODOTTI[Prodotto_Importo])),,
    DESC
)

 

Regards,
Mariusz

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

No it doesn't seems to work with the last solution.

 

It gives me rank equal to 1 for each row.

 

 

 

PowerBI_Rank5.PNG

 

 

Andrea

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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