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
rocbotman
Frequent Visitor

Measure that displays the 2nd ranked value

Hello, 

I'm trying to get a measure in a matrix table that displays the largest market share within certain categories. If they are already ranked 1, I want to display the next to highest market share. 

So far all the ranks 2 or higher, the number 1 rank for market share should return: 39,32%, but in the row where there is the number 1 market share, i want the 2nd market share to be returned: 12,29%.

I have the following measure, but when I put it in my  matrix table it won't work. 

_Potentie_marktaandeel =
IF (
    [_Rank_marktaandeel] <> 1,
    [_MaxMarktaandeel],
CALCULATE([_Aantal_marktaandeel],
FILTER(
    ALL(FEIT_HERKOMST_MBO),
    [_Rank_marktaandeel]=2
)
))

Here is a link to all the measures I used for this table: 
https://docs.google.com/document/d/1pBmx0n7TYuahbLqY-cWP2dT7aqW8DZoscBrE-LsQJWM/edit?usp=sharing

Since I'm using dynamic parameters it needs to be a measure. 
 
Thanks for the help.



jaarPROVINCIESubgroepInstellingSum of aantal_Aantal_omvang_Aantal_marktaandeel_Rank_marktaandeel_MaxMarktaandeel_Aantal_marktomvangDesired output
2022UtrechtBouwkundeROC Midden Nederland46446439,32%139,32%118012,29%
2022UtrechtBouwkundeMBO Amersfoort14514512,29%239,32%118039,32%
2022UtrechtBouwkundeMBO Utrecht13813811,69%339,32%118039,32%
2022UtrechtBouwkundeHoornbeeck College1091099,24%439,32%118039,32%
2022UtrechtBouwkundeROC A1270705,93%539,32%118039,32%
2022UtrechtBouwkundeROC van Amsterdam57574,83%639,32%118039,32%
2022UtrechtBouwkundemboRijnland48484,07%739,32%118039,32%
2022UtrechtBouwkundeRijn IJssel39393,31%839,32%118039,32%
2022UtrechtBouwkundeSOMA College28282,37%939,32%118039,32%
2022UtrechtBouwkundeROC Da Vinci College23231,95%1039,32%118039,32%
2022UtrechtBouwkundeROC Rivor21211,78%1139,32%118039,32%
2022UtrechtBouwkundeROC Nova College11110,93%1239,32%118039,32%
2022UtrechtBouwkundeKoning Willem I College770,59%1339,32%118039,32%
2022UtrechtBouwkundeCurio660,51%1439,32%118039,32%
2022UtrechtBouwkundeDeltion College440,34%1539,32%118039,32%
2022UtrechtBouwkundeStichting Landstede330,25%1639,32%118039,32%
2022UtrechtBouwkundeSumma College220,17%1739,32%118039,32%
2022UtrechtBouwkundeROC Horizon College110,08%1839,32%118039,32%
2022UtrechtBouwkundeROC Nijmegen eo110,08%1839,32%118039,32%
2022UtrechtBouwkundeROC van Flevoland110,08%1839,32%118039,32%
2022UtrechtBouwkundeROC van Twente110,08%1839,32%118039,32%
2022UtrechtBouwkundeZadkine110,08%1839,32%118039,32%
1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @rocbotman ,

Please try:

_Potentie_marktaandeel = 
var _max = MAXX(SUMMARIZE(ALLSELECTED('Table'),'Table'[jaar],'Table'[PROVINCIE],'Table'[Subgroep],'Table'[Instelling]),[_Aantal_marktaandeel])
VAR _second_max = MAXX(FILTER(SUMMARIZE(ALLSELECTED('Table'),'Table'[jaar],'Table'[PROVINCIE],'Table'[Subgroep],'Table'[Instelling]),[_Rank_marktaandeel]=2),[_Aantal_marktaandeel])
VAR _result = IF([_Rank_marktaandeel]<>1,_max,_second_max)
RETURN
_result

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

1 REPLY 1
v-cgao-msft
Community Support
Community Support

Hi @rocbotman ,

Please try:

_Potentie_marktaandeel = 
var _max = MAXX(SUMMARIZE(ALLSELECTED('Table'),'Table'[jaar],'Table'[PROVINCIE],'Table'[Subgroep],'Table'[Instelling]),[_Aantal_marktaandeel])
VAR _second_max = MAXX(FILTER(SUMMARIZE(ALLSELECTED('Table'),'Table'[jaar],'Table'[PROVINCIE],'Table'[Subgroep],'Table'[Instelling]),[_Rank_marktaandeel]=2),[_Aantal_marktaandeel])
VAR _result = IF([_Rank_marktaandeel]<>1,_max,_second_max)
RETURN
_result

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

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.