cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Dynamic Order For TopN Function in DAX

I am new to DAX and probably making a noob mistake. I want to change my TopN order to asc or desc order based on whether the selected measure is summing to positive or negative. But so far, I have not been successful with the below code. I am not sure why the DAX is not accepting OrderTopN variable in order definition. I have been able to solve it the long way but I wanted to know why the below code ain't working?

 

VAR OrderTOPN =IF([ADPR.EM]>=0,1,0)

 

TopN.ADPR =
CALCULATE (
[ADPR.EM],
TOPN (
'mn-value'[n-value Value],
ALL ( 'mprofile'[Org_Name] ),
[ADPR.EM],OrderTOPN
),
VALUES ( 'mprofile'[Org_Name] )
)

 

RETURN TopN.ADPR

0 REPLIES 0

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors