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
ROG
Resolver III
Resolver III

bottom 5 dax not working

Hello Community,

 

The dax below supposed to give me the bottom 5 carriers + the remaining (Others). Bottom is this case means negative No of Port-Outs, so I was able to get the Top5, and added the 'DESC' funcion to give the negative values. But the result is showing only the 'Others' and I'm missing the Bottom 5 Carriers. Can you help, please? How to have a dax that can show me the bottom 5 + the remaing?

 

TopN No Port-Outs =

VAR TopN_Table =
TOPN(
    5,
    ALLSELECTED(CarrierList),
    [No Port-Outs],DESC
)

VAR TopN_KeepFilters_NoPortOuts =
CALCULATE(
    [No Port-Outs],
    KEEPFILTERS(TopN_Table)
)

VAR Total_NoPortOuts =
CALCULATE(
    [No Port-Outs],
    ALLSELECTED(CarrierList)
)

VAR TopN_NoPortOuts =
CALCULATE(
    [No Port-Outs]
    ,TopN_Table
)

VAR Others_NetPorts = Total_NoPortOuts - TopN_NoPortOuts

VAR Others_isSelected = SELECTEDVALUE(CarrierList[carrier]) = "Others"

RETURN
IF (ISINSCOPE(CarrierList[carrier]), IF(Others_isSelected, Others_NetPorts, TopN_KeepFilters_NoPortOuts), Total_NoPortOuts)
 
Expected result
ROG_0-1703688703853.png

 

Real - wrong result

 ROG_1-1703688730457.png

 

Thank you!

1 ACCEPTED SOLUTION
v-yifanw-msft
Community Support
Community Support

Hi @ROG ,

 

Based on the information you have provided, you can follow these steps:

1.Add new column

 

ranking =

RANKX ( ALL ( 'Table' ), 'Table'[No Port-Outs],, DESC, DENSE )

 

2.Add new column

 

new carrier =

IF ( 'Table'[ranking] <= 5, 'Table'[carrier], "Others" )

 

 

3.Put in Matrix

Final output:

vyifanwmsft_0-1703733116909.png

 

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

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

2 REPLIES 2
v-yifanw-msft
Community Support
Community Support

Hi @ROG ,

 

Based on the information you have provided, you can follow these steps:

1.Add new column

 

ranking =

RANKX ( ALL ( 'Table' ), 'Table'[No Port-Outs],, DESC, DENSE )

 

2.Add new column

 

new carrier =

IF ( 'Table'[ranking] <= 5, 'Table'[carrier], "Others" )

 

 

3.Put in Matrix

Final output:

vyifanwmsft_0-1703733116909.png

 

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

That works! Many thanks @v-yifanw-msft 

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.