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

Calculate 2end et 3th highest value with measur

Hello family ;
I want help to display in a measure the second great value and the third also

I have 2 measure  of calculations I transformed the figure and absolute value
as shown in the photos below

thank you in advance

ines foto .png

 

2 ACCEPTED SOLUTIONS
Icey
Community Support
Community Support

Hi @Anonymous ,

 

I create a simple example that you can refer to:

 

1. Table:

table.PNG

 

2. Measures.

Percent =
CALCULATE ( SUM ( 'Table'[Value1] ) - SUM ( 'Table'[Value2] ) )
    / SUM ( 'Table'[Value2] ) * 100
ABS Percent = ABS ( [Percent] )

 

3. Then I create a Rank measure.

Rank = RANKX ( ALLSELECTED ( 'Table' ), [ABS Percent],, DESC, DENSE )

rank2.PNG

 

4. Create measure to show 1st, 2nd, 3nd highest value.

1st highest value = CALCULATE([ABS Percent],FILTER('Table',[Rank]=1))
2nd highest value = CALCULATE([ABS Percent],FILTER('Table',[Rank]=2))
3rd highest value = CALCULATE([ABS Percent],FILTER('Table',[Rank]=3))

rank.PNG

 

For more details, please check the attached PBIX file.

 

 

Best Regards,

Icey

 

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

 

View solution in original post

Icey
Community Support
Community Support

Hi @Anonymous ,

 

If you want the Rank value changed by the Date range you selected, the measure above can meet your requirement. Because I used "ALLSELECTED" in the expression.

range.gif

 

 

Best Regards,

Icey

 

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

 

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

RANKX allows you to sort your table based on a measure that you would like


So I suggest to create a virtual table with a SUMMARIZE, representing in memory your table as in the visual, then adding a RANKX. It will add a column with numbers 1 to N where 1 is the first, 2 is the second etc. 
Then with a FILTER you can choose the 1st, 2nd etc.

 

Anonymous
Not applicable

Exactly yes; @Anonymous 
I have already made the rank but what I really want is to display it in a measure like the max function which takes the 1st I want to know is what we can do a compound function to have a measure displays the 2end and 3thd value 

 

Icey
Community Support
Community Support

Hi @Anonymous ,

 

I create a simple example that you can refer to:

 

1. Table:

table.PNG

 

2. Measures.

Percent =
CALCULATE ( SUM ( 'Table'[Value1] ) - SUM ( 'Table'[Value2] ) )
    / SUM ( 'Table'[Value2] ) * 100
ABS Percent = ABS ( [Percent] )

 

3. Then I create a Rank measure.

Rank = RANKX ( ALLSELECTED ( 'Table' ), [ABS Percent],, DESC, DENSE )

rank2.PNG

 

4. Create measure to show 1st, 2nd, 3nd highest value.

1st highest value = CALCULATE([ABS Percent],FILTER('Table',[Rank]=1))
2nd highest value = CALCULATE([ABS Percent],FILTER('Table',[Rank]=2))
3rd highest value = CALCULATE([ABS Percent],FILTER('Table',[Rank]=3))

rank.PNG

 

For more details, please check the attached PBIX file.

 

 

Best Regards,

Icey

 

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

 

Anonymous
Not applicable

@Icey  

thank you for your solution
it's professional work on your part

I have a problem if we want to add the date for example the rank does not change

for example :

calculate the 1st 2nd 3rd of the date Feb 15 ----> March 3
calculate the 1st 2nd 3rd of the date Jan 10 ----> Apr 1

it means when you choose a date range the rank changes according to date range 

 

Icey
Community Support
Community Support

Hi @Anonymous ,

 

If you want the Rank value changed by the Date range you selected, the measure above can meet your requirement. Because I used "ALLSELECTED" in the expression.

range.gif

 

 

Best Regards,

Icey

 

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

 

Anonymous
Not applicable

 @Icey  I am proud to be part of the Power Bi family
thank you it's too professional especially the aspect of sharing and help

 

I have a little problem with the rank when we have a null value it considers 0 as a 1st rank

how not to take null values

 

Mesures : 

2.png

 

1.png

resultat : 

3.png

 

 

Icey
Community Support
Community Support

Hi @Anonymous ,

 

If you want to show the records with null values, you can change your Measure like so:

Rank =
IF (
    [ABS Percent] <> 0,-----------You can replace 0 with BLANK() in your scenario.
    RANKX (
        FILTER ( ALLSELECTED ( 'Table' ), [ABS Percent] <> 0 ),----You can replace 0 with BLANK() in your scenario.
        [ABS Percent],
        ,
        ASC,
        DENSE
    )
)

rank3.PNG

If you don't want to show the records with null value, just try something like below to filter the visual.

rank4.PNG

 

 

Best Regards,

Icey

 

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

 

Anonymous
Not applicable

@Icey  

Thank you sir we are too good for the first exercise
that's another one or I want the row to start with 1 but as you see in the picture it starts with 1 in a null value 

 

3.png

 

thank you 

 

Icey
Community Support
Community Support

Hi @Anonymous ,

 

If the screenshot below is like what you want, please try the expression above.

rank5.PNG

 

Best Regards,

Icey

 

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

 

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.