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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

How to have lookup values in another table with condition?

Hi There,

 

I have two source of table which i would like to combine my data.

 

Table 1 contains information of the actual spend of the product code and the sourcing status. The principal name has an error for all code that has 'Single' as their sourcing status:

CodeSpendPrincipalSourcing Status
10101000AgentSingle
10132000AgentSingle
10431400AgentSingle
1238300AgentSingle
12692344Principal AMultiple
12693045Principal DMultiple
1138450Principal AMultiple
1138130Principal BMultiple
1123450Principal CMultiple
1123444Principal DMultiple

 

Table 2 has the correct principal information:

CodePrincipalSourcing Status
1010Principal ASingle
1013Principal BSingle
1043Principal CSingle
1238Principal ASingle
1269Principal AMultiple
1269Principal DMultiple
1138Principal AMultiple
1138Principal BMultiple
1123Principal CMultiple
1123Principal DMultiple

 

How do i use Lookupvalue function to get the principal value for code that has "Single" status? Lookupvalue will return error if it lookup for code that has "Multiple" status as it will return multiple value where a single value is expected. 

 

Desired output:

CodeSpendPrincipalCorrect Principal
10101000AgentPrincipal A
10132000AgentPrincipal B
10431400AgentPrincipal C
1238300AgentPrincipal A
12692344Principal APrincipal A
12693045Principal DPrincipal D
1138450Principal APrincipal A
1138130Principal BPrincipal B
1123450Principal CPrincipal C
1123444Principal DPrincipal D
1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To create a calculated column in Table 1.

Column = 
IF (
    'Table1'[Sourcing Status] = "Single",
    LOOKUPVALUE ( Table2[Principal], Table2[Code], Table1[Code] ),
    Table1[Principal]
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To create a calculated column in Table 1.

Column = 
IF (
    'Table1'[Sourcing Status] = "Single",
    LOOKUPVALUE ( Table2[Principal], Table2[Code], Table1[Code] ),
    Table1[Principal]
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

hI @Anonymous 
Try the following measure

Measure =
VAR __complete = "Single"
RETURN
CALCULATE(
MAX( Table2[Principal] ),
CUSTOMERS[Sourcing Status] = __complete
)
 a little trick I learned this week
 
Thanks!
Anonymous
Not applicable

Hi @Anonymous ,

 

The solution you proposed only returns one principal from Table 2.

 

Now the  code with the "Multiple" status is also returning Principal C, whereas i originally wanted the previous correct principal to remain. 

 

Any ideas on how to solve this?

 

 

 

Correct Principal Case Study.PNG

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.