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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
hansei
Helper V
Helper V

Alternatives to LOOKUPVALUE

I have a measure that evaluates some selections to get a rate table, possibly like the following

 

 

sel:= switch(selectedvalue(whatif[column], 0), 1, "v1", 2, "v2", "v3")

 

 

 

and a table of various numbers

codev1v2v3
abc1115
def2416

 

and i'd like to retrieve the value, as if this was valid

 

 

abc:= lookupvalue(table[<sel>], table[code], "abc")

 

 

 

Is there a clean way to do this? Avoiding decision blocks like

 

abc:= switch(sel, 
   "v1", lookupvalue(table[v1], table[code], "abc"),
   "v2", lookupvalue(table[v2], table[code], "abc"),
   lookupvalue(table[v3], table[code], "abc")
)

 

This is cleaner, but still a hack and not sustainable

abc= 
   var vt1 = SELECTCOLUMNS( FILTER( table, [code] = "abc" ), "col", SWITCH( [sel], "v1", [v1], "v2", [v2], [v3] ) )
   return FIRSTNONBLANK( vt1, 1 )

 

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@hansei Honestly, I'm not even sure what exactly you are trying to do or what the expected outcome is that you want but pretty sure that you can't take a text string and suddenly treat it as a column name.

 

I think the main problem you are having is that you need to unpivot your v1, v2, v3 columns.

 

The general LOOKUPVALUE equivalent is MAXX(FILTER(...)...) but you still can't magically transform text into something that can be used as a column reference.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Agreed, unpivoting is the easy way to go.

 

And I didn't think the desire to reference a column dynamically was considered 'magical'. Just like one might use Record.Field(var, "abc") instead of var[abc] in M when the field name was dynamic.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.