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
waitehamrick
Helper I
Helper I

Measure Name and Value in a Dax

Hi, 

 

I am trying to find a way to pull the max value from a list measure and pull in the measure name. Im using the below dax but the output is always "Unknown Measure" [Value]. I would like it to be "% PR PR Tax PY Change" [Value]. Can someone help with this dax? 

 

Max Expense Component =
Var MaxValue = {[% PR PR Tax PY Change],[% PR Grp Ins PY Change],[% PR Union PY Change],[% PR Union Medical PY Change],[% PR Workers Comp PY Change],[% PR 401K PY Change],[% PR PABA PY Change]}
Var MaxMeasure = SELECTEDMEASURENAME()
Var Selected =
 SWITCH(
        MaxMeasure,
        "[% PR PR Tax PY Change]", "PR Tax",
        "% PR Grp Ins PY Change", "Grp Ins",
        "% PR Union PY Change", "Union",
        "% PR Union Medical PY Change", "Union Medical",
        "% PR Workers Comp PY Change", "Workers Comp",
        "% PR 401K PY Change", "401K",
        "% PR PABA PY Change", "PABA",
        "Unknown Measure"
    )

Return
Selected &" " & MAXX(MaxValue,format([Value],"0.0%"))
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@waitehamrick ,

Refer my example, My measure are net and gross

 

Max Value = Maxx(Union(row("Gross", [Gross]), row("Net", [Net])), [Gross])
 
Max Value Name =
var _tab = Union(row("Name", "Gross", "Value", [Gross]), row("Name,", "Net", "Value", [Net]))
return
Maxx(filter(_tab, [Value] = [Max Value]),[Name])
 
amitchandak_0-1678888803660.png

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@waitehamrick ,

Refer my example, My measure are net and gross

 

Max Value = Maxx(Union(row("Gross", [Gross]), row("Net", [Net])), [Gross])
 
Max Value Name =
var _tab = Union(row("Name", "Gross", "Value", [Gross]), row("Name,", "Net", "Value", [Net]))
return
Maxx(filter(_tab, [Value] = [Max Value]),[Name])
 
amitchandak_0-1678888803660.png

 

I tried this solution but it is always returning the same category ("PR Tax") for all rows in my tabel.  

Max Expense Component =
Var MaxValue = MAXX(Union(row("PR Tax",[% PR PR Tax PY Change]),row("Grp Ins",[% PR Grp Ins PY Change]),row("Union Pension",[% PR Union PY Change]),row("Union Medical",[% PR Union Medical PY Change]),row("Workers Comp",[% PR Workers Comp PY Change]),row("401K",[% PR 401K PY Change]),row("PABA",[% PR PABA PY Change])),[% PR PR Tax PY Change])

Var _tab = Union(row("Name", "PR Tax", "Value", [% PR PR Tax PY Change]), row("Name,", "Grp Ins", "Value", [% PR Grp Ins PY Change]), row("Name,", "Union Pension", "Value", [% PR Union PY Change]), row("Name,", "Union Medical", "Value", [% PR Union Medical PY Change]), row("Name,", "Workers Comp", "Value", [% PR Workers Comp PY Change]), row("Name,", "401K", "Value", [% PR 401K PY Change]), row("Name,", "PABA", "Value", [% PR PABA PY Change]))

Var Maxnumber = {[% PR PR Tax PY Change],[% PR Grp Ins PY Change],[% PR Union PY Change],[% PR Union Medical PY Change],[% PR Workers Comp PY Change],[% PR 401K PY Change],[% PR PABA PY Change]}

Return
MAXX(FILTER(_tab,[Value]=MaxValue),[Name]) & " " & MAXX(MaxNumber,format([Value],"0.0%"))

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.