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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
rmcgrath
Advocate II
Advocate II

Help with a lookup?

I am trying to make a custom column that would use these three values and if it matches any of the three in a column from a different table, it will return a value from that table.  Here are the three values:

rmcgrath_0-1741391098997.png

Here is the other table...it needs to match one of those first three values to Column "Site Lookup" and return the value in "Site"

rmcgrath_1-1741391217739.png

So in this example it should return "Admin" since CVF_030, CVF_030-000 and CVF_000-000 do not exist in the Site Lookup column of the second table, but CVF_000 does.

 

2 ACCEPTED SOLUTIONS
techies
Super User
Super User

Hi @rmcgrath are you looking for lookupvalue function in dax ?

 

Column =
VAR Match1 = LOOKUPVALUE('Site Table'[Site], 'Site Table'[Site Lookup], 'First Table'[Dept Loc Code])
VAR Match2 = LOOKUPVALUE('Site Table'[Site], 'Site Table'[Site Lookup], 'First Table'[Department Code])
VAR Match3 = LOOKUPVALUE('Site Table'[Site], 'Site Table'[Site Lookup], 'First Table'[Location Code])

RETURN
COALESCE(Match1, Match2, Match3, "No Match")

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

View solution in original post

Please try to avoid LOOKUPVALUE. If there is a data model, use the data model. If there isn't, use TREATAS.  LOOKUPVALUE should be the very last resort.

View solution in original post

4 REPLIES 4
techies
Super User
Super User

Hi @rmcgrath are you looking for lookupvalue function in dax ?

 

Column =
VAR Match1 = LOOKUPVALUE('Site Table'[Site], 'Site Table'[Site Lookup], 'First Table'[Dept Loc Code])
VAR Match2 = LOOKUPVALUE('Site Table'[Site], 'Site Table'[Site Lookup], 'First Table'[Department Code])
VAR Match3 = LOOKUPVALUE('Site Table'[Site], 'Site Table'[Site Lookup], 'First Table'[Location Code])

RETURN
COALESCE(Match1, Match2, Match3, "No Match")

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

Please try to avoid LOOKUPVALUE. If there is a data model, use the data model. If there isn't, use TREATAS.  LOOKUPVALUE should be the very last resort.

rmcgrath
Advocate II
Advocate II

Here is the code I tried and it errors out, telling me it cannot find Department Code

 

= Table.AddColumn(#"Changed Type", "Site", each let
departmentMatch = Table.SelectRows(Mapping, each [Site Lookup] = [Department Code]),
locationMatch = Table.SelectRows(Mapping, each [Site Lookup] = [Location Code]),
deptLocMatch = Table.SelectRows(Mapping, each [Site Lookup] = [Dept Loc Code]),
siteValue = if Table.RowCount(departmentMatch) > 0 then departmentMatch{0}[SITE]
else if Table.RowCount(locationMatch) > 0 then locationMatch{0}[SITE]
else if Table.RowCount(deptLocMatch) > 0 then deptLocMatch{0}[SITE]
else null
in
siteValue)

ArwaAldoud
Super User
Super User

Hi @rmcgrath 
Please share sample data that clearly represents your issue or question. Make sure not to include any sensitive or unrelated information.

 

check this to upload your data
https://community.fabric.microsoft.com/t5/Power-BI-Community-Blog/How-to-provide-sample-data-in-the-...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors