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
94veiga
Helper II
Helper II

Table with TOP N category

I have a table like this

 

IdEMPProfessionIncome
EMP0001Chef200
EMP0001Waiter100
EMP0001Sous-Chef50
EMP0002Sous-Chef300
EMP0002Waiter100

 

I want to get a table that shows me the profession in which they get the most of their income. It should be like this.

 

IdEMPProfession
EMP0001Chef
EMP0002Sous-Chef

 

Thank you very much for your support.

 

Pedro V.

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @94veiga ,

You can create a measure like this, put it in the visual filter and set its value as 1:

Rank = 
CALCULATE (
    RANKX (
        FILTER ( ALL ( 'Table' ), 'Table'[IdEMP] IN DISTINCT ( 'Table'[IdEMP] ) ),
        'Table'[Income],
        SUM ( 'Table'[Income] ),
        DESC,
        DENSE
    )
)

rank.png

Attached a sample file in the below, hopes it could help.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @94veiga ,

You can create a measure like this, put it in the visual filter and set its value as 1:

Rank = 
CALCULATE (
    RANKX (
        FILTER ( ALL ( 'Table' ), 'Table'[IdEMP] IN DISTINCT ( 'Table'[IdEMP] ) ),
        'Table'[Income],
        SUM ( 'Table'[Income] ),
        DESC,
        DENSE
    )
)

rank.png

Attached a sample file in the below, hopes it could help.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@94veiga , assuming income is measure, create a rank like

 

rankx(filter(allselected(table[Profession], Table[EMP] ), table[Profession] = max(table[Profession])),[Income],,desc,)

 

 

and use a visual level filter rank =1

94veiga_0-1615828403806.png

Idk why but the result is a number. 

 

Categ = rankx(filter(allselected(LiquidacionesDetalle[CatFact], LiquidacionesDetalle[idautor] ), LiquidacionesDetalle[idautor] = max(LiquidacionesDetalle[CatFact])),'Detalle medidas'[Total Detalle BI],1,desc)
 
Any mistake in here?

@94veiga , if it is a column then you need to have a column rank like

'Detalle medidas'[Total Detalle BI]

 

Categ = rankx(filter(LiquidacionesDetalle, LiquidacionesDetalle[idautor] = earlier(LiquidacionesDetalle[CatFact])),'Detalle medidas'[Total Detalle BI],,desc)

 

can you share data with original column names

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

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.