cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
aviv5777
Helper I
Helper I

show my company and top 4 in visualization

Hi,

I hope you can assist me,

I need to show in a visualization top 5 companies with the biggest ebit , I use the top N filter, But even when the company I work for is not in the TOP 5 I need it to appear so that it will show my company and the TOP 4, what is the way to do that?

 

Thank you,

1 ACCEPTED SOLUTION
CNENFRNL
Super User
Super User

RANK = 
VAR __rnk = RANKX( ALLSELECTED( EBIT[Company] ), [Total] )
RETURN
    IF(
        MAX( EBIT[Company] ) = "My Company"
            || __rnk <= MAX( 'TOP'[Value] ),
        __rnk
    )

Record_2022_08_10_21_05_57_45.gif


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
CNENFRNL
Super User
Super User

RANK = 
VAR __rnk = RANKX( ALLSELECTED( EBIT[Company] ), [Total] )
RETURN
    IF(
        MAX( EBIT[Company] ) = "My Company"
            || __rnk <= MAX( 'TOP'[Value] ),
        __rnk
    )

Record_2022_08_10_21_05_57_45.gif


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

jdbuchanan71
Super User
Super User

@aviv5777 

You can write a measure that calcualtes the [EBIT] for the top 5 and your company and filters the results to that list of companies.

Here is an example using a [Sales Amount] measure but the pattern would be the same, just need to change the names to match your model.

Top 5 + my company = 
VAR _TOPN = TOPN(5,ALL('Customer'[Company]),[Sales Amount])
VAR _MyCompany = FILTER(VALUES('Customer'[Company]),'Customer'[Company] = "AlbanyCompany")
VAR _List = UNION(_TOPN,_MyCompany)
RETURN
CALCULATE(
    [Sales Amount],
    KEEPFILTERS(_List)
)

You can see the measure returns the top 5 plus the company I have marked as _MyCompany even though their amount is lower then others:

jdbuchanan71_0-1660144641677.png

This will show 6 if your company is not in the top 5 or only 5 if your company is in the top 5.

 

Helpful resources

Announcements
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors