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,
Solved! Go to Solution.
RANK =
VAR __rnk = RANKX( ALLSELECTED( EBIT[Company] ), [Total] )
RETURN
IF(
MAX( EBIT[Company] ) = "My Company"
|| __rnk <= MAX( 'TOP'[Value] ),
__rnk
)
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! |
RANK =
VAR __rnk = RANKX( ALLSELECTED( EBIT[Company] ), [Total] )
RETURN
IF(
MAX( EBIT[Company] ) = "My Company"
|| __rnk <= MAX( 'TOP'[Value] ),
__rnk
)
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! |
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:
This will show 6 if your company is not in the top 5 or only 5 if your company is in the top 5.
User | Count |
---|---|
106 | |
88 | |
69 | |
52 | |
49 |
User | Count |
---|---|
148 | |
94 | |
79 | |
71 | |
70 |