Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Akhil_1411
Helper IV
Helper IV

Bottom N giving incorrect result

Hi All,

 

I have calculated Bottom N dax and used as a slicer. If i enter bottom 5 in slicer it is giving only 4 likewise. Can anyone help me out.

 

Dax formula : - 

Bottom Sales =
var A = RANKX(ALL(Orders[Customer Name]),CALCULATE(SUM(Orders[Sales])),,ASC,Dense)
return
IF(A<=SELECTEDVALUE('Bottom Sales'[Bottom Sales]),1,0)
 
Screenshot:-
 
Thanks,
Akhil.bottom N.PNG
1 ACCEPTED SOLUTION

Hi @Akhil_1411 ,

 

I am glad that you could find the solution. You can accept your own reply to close this topic.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

7 REPLIES 7
mahoneypat
Microsoft Employee
Microsoft Employee

You can try this measure instead

 

Bottom N Sales =
VAR __slicervalue =
    SELECTEDVALUE ( 'Bottom Sales'[Bottom Sales] )
VAR __topN =
    TOPN (
        __slicervalue,
        ALL ( Orders[CustomerName] ),
        CALCULATE ( SUM ( Orders[Sales] ) ), ASC
    )
RETURN
    CALCULATE ( SUM ( Order[Sales] ), KEEPFILTERS ( __topN ) )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat ,

 

Thanks for your reply😊. The dax which u have given is giving the right result. But, when i apply the Sales amount as a slicer value it is giving the blank result. The Bottom N should also be filtered by the range of sales amount.🤔

Please check my file.

 

Thanks,

Akhil.

Try changing ALL to ALLSELECTED. Please let me know if that doesn't work.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat , Nope😐

Ok.  VALUES( ) around Customer Name instead of ALL( ) should do it.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


It is not working with Values(). But, thanks for your time.😊

 

I have re-written the dax now it is giving the expected result.

 

Bottom Sales =
var A = RANKX(ALLSELECTED(Orders[Customer Name]),CALCULATE(SUM(Orders[Sales])),,ASC,Dense)
return
IF(ISFILTERED(Orders[sales customer]),IF(A<=SELECTEDVALUE('Bottom Sales'[Bottom Sales])+1,SUM(Orders[Sales]),BLANK()),IF(A<=SELECTEDVALUE('Bottom Sales'[Bottom Sales]),SUM(Orders[Sales]),BLANK())
)
 
Thanks,
Akhil.

Hi @Akhil_1411 ,

 

I am glad that you could find the solution. You can accept your own reply to close this topic.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.