A more elegant solution than an If statement

JEB85

Board Regular
Joined
Aug 13, 2010
Messages
238
Hi Guys,

Is there a way to return the measure name in a DAX formula that produces the maximum value?

For example, lets say I have 3 measures that yield:

Measure 1: 25
Measure 2: 32
Measure 3: 28

I would like to create a formula which would return ‘Measure 2’ in this instance since it is the largest value.

I know this is achievable through an if statement but I wondered if there was a more elegant solution since I have lots of conditions in reality

Thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Mackers

Well-known Member
Joined
Nov 4, 2013
Messages
536
Hi

I might be misinterpreting the question, but if you have those three as strings in A2:A4 and the numbers are always 1 or 2 digits, you can use as an array function (ctrl+shift+enter):

=INDEX(A2:A4, MATCH(MAX(--RIGHT(A2:A4,2)), --RIGHT(A2:A4, 2), 0))

If Measure1, Measure2 and Measure3 are in column A and the numbers are in column B it is a lot easier (no need for an array function):

=INDEX(A2:A4, MATCH(MAX(B2:B4), B2:B4, 0))

If the number varies more in length there are fancier ways of chopping this bit out, but it sounds like your main question was about how to extract the largest value.
 
Upvote 0

JEB85

Board Regular
Joined
Aug 13, 2010
Messages
238
Hi,

thanks but the measures are dax measures. I'm wanting to return the name of the dax measure that yields the largest value.

you' re right, I could go down the route you have suggested but I was hoping to calculate the result through another dax measure.

thanks
 
Upvote 0

scottsen

Well-known Member
Joined
Mar 16, 2014
Messages
1,263
Other than using SWITCH() instead of IF() .... I can't think of a way off hand. I can maybe possible imagine a different solution depending on what all those measures are doing... but I doubt it :)
 
Upvote 0

Forum statistics

Threads
1,195,640
Messages
6,010,873
Members
441,571
Latest member
stolenweasel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top