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
RobWayne
Frequent Visitor

Lookup selected cell value from a range of columns and return a result

Hello to all the community,

I am trying to use DAX to return a result between two tables not directly connected between each other.

Table 1

NameJobLevel
AlanAccountantI
MarkAccountantII
JohnManagerIII

 

Job List

JobIIIIII
AccountantBCD
ManagerDEF

 

By taking the parameters Job + Level, I would like to return the corresponding value for each name based on level

Table 1

Name

JobLevelValue
AlanAccountantIB
MarkAccountantIIC

 

Current solution that I have found is to do a lot of nested lookupvalues 

IF(Level="I",LOOKUPVALUE('JOB LIST'[I],'JOB LIST'[JOB],Job),IF(Level="II",LOOKUPVALUE('JOB LIST'[II],'JOB LIST'[JOB],Job),IF(Level="III",LOOKUPVALUE('JOB LIST'[III],'JOB LIST'[JOB],Job),IF(Level="IV",LOOKUPVALUE('JOB LIST'[IV],'JOB LIST'[JOB],Job))))),LOOKUPVALUE('JOB LIST'[No Level],'JOB LIST'[JOB],Job)).
 
I would like to learn a more optimised way to do it,
I have tried by unpivoting of the columns but I am not sure how to write a condition to similar to IF ( Table1 [Job] + Table1 [Level] = Job List [Job] + Unpivot Job List [Level] )
Return Value
 
your clairvoyance and expertise is much appreciated
 
1 REPLY 1
dedelman_clng
Community Champion
Community Champion

Hi @RobWayne -

 

Unpivoting Job List is the first step. You want the data to look like this:

 

Job Level Value
Accountant I B
Accountant II C
Accountant III D
Manager I D
Manager II E
Manager III F

 

Then the DAX should be straightforward

 

JobValue =
LOOKUPVALUE (
    JobList[Value],
    JobList[Title], Table1[Title],
    JobList[Level], Table1[Level]
)

 

 

Hope this helps

David

 

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.

Top Solution Authors