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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
powertechbi
Frequent Visitor

Help With High and Lower Ranks

Good afternoon

I'm putting together a dashboard and I'm stuck on a question.

I need to create a graph that shows the largest / smallest values ​​depending on the quantity selected. In other words, I am creating a ranking where the user selects how many values ​​they want to see and whether they want to see the ranking of highest values ​​or lowest values.

I created all the measurements. And I was successful in bringing the highest values, but when I select the option to bring the lowest values ​​it doesn't bring anything.

I included the images below with the measurements and everything. If anyone can help me, I'd appreciate it.

 

HELP 3.jpgHELP 2.jpgHELP 1.jpg

1 ACCEPTED SOLUTION

Hi @powertechbi 

 

The lowest value is shown as null because there are some null values in your data, and your Measure recognizes null values as the minimum values.

When I debug your measure, it returns something like this:

vzhengdxumsft_0-1731461333411.png

What you need to do is to filter the measure as not blank, please try this measure:

 

TopN =
VAR Tops =
    SELECTEDVALUE ( 'Rank Bairro'[Rank Bairro] )
VAR Maior =
    SELECTEDVALUE ( Ordem[ordem] ) = "Maiores"
VAR Menor =
    SELECTEDVALUE ( Ordem[ordem] ) = "Menores"
VAR TopMaior =
    CALCULATE (
        [Medidas Dinamicas Venda],
        KEEPFILTERS (
            TOPN ( Tops, ALL ( Imoveis[Bairro] ), [Medidas Dinamicas Venda], DESC )
        )
    )
VAR TopMenor =
    CALCULATE (
        [Medidas Dinamicas Venda],
        KEEPFILTERS (
            TOPN (
                Tops,
                FILTER ( ALL ( Imoveis[Bairro] ), [Medidas Dinamicas Venda] <> BLANK () ),
                [Medidas Dinamicas Venda], ASC
            )
        )
    )
RETURN
    SWITCH ( TRUE (), Maior, TopMaior, Menor, TopMenor, [Medidas Dinamicas Venda] )

 

The result is as follow:

vzhengdxumsft_1-1731461469169.png

 

Best Regards

Zhengdong Xu
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

7 REPLIES 7
v-zhengdxu-msft
Community Support
Community Support

Hi @powertechbi 

 

I did some test, but your measure seems working well in my side, I can't reproduce your problem.

 

So if possible, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

 

 

Best Regards

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

 

Good morning

Thanks for the answer.

I am attaching the Pbix file with the information I am working on.

When you open it, you can see that when I ask for the highest values ​​to be displayed according to the measure and rank applied, it is being displayed correctly. However, when requesting that the smallest values ​​be displayed, the graph and table are blank

 

Link File PBIX: 

https://drive.google.com/file/d/1xFk97jH8hI1CDsr3UVmkZa8wOsux_Uwz/view?usp=sharing 

Hi @powertechbi 

 

Sorry for the late reply, I'm requesting access:

vzhengdxumsft_0-1731394884403.png

 

 

Best Regards

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

Hi @powertechbi 

 

The lowest value is shown as null because there are some null values in your data, and your Measure recognizes null values as the minimum values.

When I debug your measure, it returns something like this:

vzhengdxumsft_0-1731461333411.png

What you need to do is to filter the measure as not blank, please try this measure:

 

TopN =
VAR Tops =
    SELECTEDVALUE ( 'Rank Bairro'[Rank Bairro] )
VAR Maior =
    SELECTEDVALUE ( Ordem[ordem] ) = "Maiores"
VAR Menor =
    SELECTEDVALUE ( Ordem[ordem] ) = "Menores"
VAR TopMaior =
    CALCULATE (
        [Medidas Dinamicas Venda],
        KEEPFILTERS (
            TOPN ( Tops, ALL ( Imoveis[Bairro] ), [Medidas Dinamicas Venda], DESC )
        )
    )
VAR TopMenor =
    CALCULATE (
        [Medidas Dinamicas Venda],
        KEEPFILTERS (
            TOPN (
                Tops,
                FILTER ( ALL ( Imoveis[Bairro] ), [Medidas Dinamicas Venda] <> BLANK () ),
                [Medidas Dinamicas Venda], ASC
            )
        )
    )
RETURN
    SWITCH ( TRUE (), Maior, TopMaior, Menor, TopMenor, [Medidas Dinamicas Venda] )

 

The result is as follow:

vzhengdxumsft_1-1731461469169.png

 

Best Regards

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

Thank you so much!

Working Perfect Now !

rajendraongole1
Super User
Super User

Hi @powertechbi - From your screenshot, I see that you've set up measures for calculating dynamic rankings, but the issue seems to occur when you try to display the lowest values.

In your Medidas Dinamicas Venda measure, the SWITCH function seems to check if _MedidasAtivas=0 to show the highest or lowest values. Ensure that this condition matches the selected option for "lowest values."

It appears you're using SELECTEDVALUE to get the user's choice from a slicer or parameter. Make sure the slicer or parameter you’re using is correctly connected to _MedidasAtivas and that it has appropriate values (e.g., 0 for highest values, 1 for lowest values).

If the existing ranking isn’t working as expected, you might consider creating a separate measure using RANKX.

Rank =
RANKX(
ALLSELECTED(TableName),
[Your Measure],
,
ASC/DESC,
Dense/Skip
)

Create a Parameter for Top/Bottom Selection and use it in your measure.
Use RANKX in your measure to dynamically sort and filter based on the top/bottom selection.

 

If these steps don’t resolve the issue, feel free to share more details





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

October NL Carousel

Fabric Community Update - October 2024

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