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

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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

@Anonymous 

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
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.