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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Jakub_Poweska11
Frequent Visitor

How to correct create measure which shows me top 10 values using fields parameter

Hello,
I am using two fields parameter with some categories, markets etc, because i want to give user to change between dimensions using slicers to investigate different values. One of them is used on X-axis, second is used in legend. I have a problem with measure top10, because its working but only when i dont have added field legend.
Measure for Top10:

RANK10Values =
SWITCH(
    TRUE(),
    SELECTEDVALUE('Dim Inc - X axis for Top Values'[Dim Inc - X axis for Top Values Fields]) = "'Incidents'[Configuration Item]",
    RANKX(
        ALLSELECTED('Incidents'[Configuration Item]),
        [Top 5 Categories inside Created Tickets],
        ,
        DESC
    )
)

Measure [Top 5 Categories inside Created Tickets]:
Top 5 Categories inside Created Tickets =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents'[assignment_group.name]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL ( 'Incidents'[assignment_group.name] ),
                [new per month], DESC
            ),
            'Incidents'
        ),
        SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents'[Configuration Item]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL ( 'Incidents'[Configuration Item] ),
                [new per month], DESC
            ),
            'Incidents'
        ),
        SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents'[business_service.name]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL ( 'Incidents'[business_service.name] ),
                [new per month], DESC
            ),
            'Incidents'
        ),
        SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents'[Platforms]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL ( 'Incidents'[Platforms] ),
                [new per month], DESC
            ),
            'Incidents'
        ),
        SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents'[Grouping Based on BS and CI]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL ( 'Incidents'[Grouping Based on BS and CI] ),
                [new per month], DESC
            ),
            'Incidents'
        ),
        SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents'[u_cause_source]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL ( 'Incidents'[u_cause_source] ),
                [new per month], DESC
            ),
            'Incidents'
        ),
        SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents'[priority]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL ( 'Incidents'[priority] ),
                [new per month], DESC
            ),
            'Incidents'
        ),
        SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents'[state]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL ( 'Incidents'[state] ),
                [new per month], DESC
            ),
            'Incidents'
        ),
        SELECTEDVALUE ( 'Dim Incidents'[Dim Incidents Fields] ) = "'Incidents Markets'[u_markets]",
        CALCULATE (
            [new per month],
            TOPN (
                5,
                ALL( 'Incidents Markets'[u_markets] ),
                [new per month], DESC
            ),
            'Incidents Markets'
        )
Jakub_Poweska11_0-1739951863727.png

 




3 REPLIES 3
Anonymous
Not applicable

Hi @Jakub_Poweska11 ,

Could you please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples here? It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

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

 

Thanks for your understanding. Your time and cooperation are much valued by us. We are looking forward to hearing from you to assist further.

Best regards,

Lucy Chen

 

 

 

bhanu_gautam
Super User
Super User

@Jakub_Poweska11 , Try using

 

DAX
RANK10Values =
SWITCH(
TRUE(),
SELECTEDVALUE('Dim Inc - X axis for Top Values'[Dim Inc - X axis for Top Values Fields]) = "'Incidents'[Configuration Item]",
RANKX(
ALLSELECTED('Incidents'[Configuration Item], 'Incidents'[LegendField]),
[Top 5 Categories inside Created Tickets],
,
DESC
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hey i am adding to legend field from second field parameter:
 'Dim Incidents'[Dim Incidents Fields]
i dont have this field in my table 'Incidents'[LegendField]. I change fields on chart using slicers

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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