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
krzysztof
Helper III
Helper III

Defining the position of the company - RANK

I have a problem with the creation of a measure that determines the position of company A in relation to other companies at a price.


1.PNG

https://drive.google.com/file/d/1P9Dtuv4m4boBElNUqFCqenWOPM1h3liK/view?usp=sharing               <-- pbx

1 ACCEPTED SOLUTION

@krzysztof 

 

Give this a shot

 

Measure =
COUNTROWS (
    FILTER (
        VALUES ( Data[company] ),
        [lowest price company A] > CALCULATE ( MIN ( Data[cost_per_day] ) )
    )
) + 1

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @krzysztof ,

You can try to use following formula to calculate rank:

rank = 
VAR summary =
    SUMMARIZE (
        FILTER ( ALL ( Data ), [company] = "A" ),
        [company],
        [car_class],
        [car_gearbox],
        [localization],
        [days],
        "minPrice", MIN ( Data[cost_per_day] )
    )
VAR currPrice =
    CALCULATE (
        MIN ( Data[cost_per_day] ),
        FILTER (
            ALLSELECTED ( Data ),
            [company] = "A"
                && Data[car_class] = EARLIER ( Data[car_class] )
                && Data[car_gearbox] = EARLIER ( Data[car_gearbox] )
                && Data[localization] = EARLIER ( Data[localization] )
                && Data[days] = EARLIER ( Data[days] )
        )
    )
RETURN
    IF ( [company] = "A", COUNTROWS ( FILTER(summary,[minPrice]>currPrice ) )+1)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you @v-shex-msft for your response. Unfortunately, your calculation is not working properly, it shows very large numbers. In the picture, I described more precisely what I am asking for

1.PNG

 

@krzysztof 

 

Also we can use RANKX function

 

Measure 2 =
RANKX (
    VALUES ( Data[company] ),
    CALCULATE ( MIN ( Data[cost_per_day] ) ),
    [lowest price company A],
    ASC,
    DENSE
)

 

 


Regards
Zubair

Please try my custom visuals

@krzysztof 

 

Give this a shot

 

Measure =
COUNTROWS (
    FILTER (
        VALUES ( Data[company] ),
        [lowest price company A] > CALCULATE ( MIN ( Data[cost_per_day] ) )
    )
) + 1

Regards
Zubair

Please try my custom visuals

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.