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
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
Employee
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
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.