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
Anonymous
Not applicable

Lookup in Diff Table if No Match then Default Value

I have two different tables that have a relationship built. Many:1 on the Country_Item column (Sales:Items).

 

I want to do a calculated column that is a lookup that says if there is a match on the field between the two columns, then return the matching price from Items. If there is no match in the Items table, then return the price for US. 

 

Table 1: Items

 

Headers:

Country_Item       ListPrice

us_P123                1.15

ca_P123                2.00

 

Table 2: Sales

 

Headers:

SalesOrder    Country_Item       ListPrice

MX12355       mx_P123              (us_P123 price is what I want here)

 

 

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

I created two tables with the dummy data below:

 

q4.PNG

We can create a calculated column below in Sales table:

 

ListPrice = IF(ISBLANK(RELATED(Items[ListPrice])),CALCULATE(MAX('Items'[ListPrice]),FILTER('Items','Items'[Country_Item]="us_P123")),RELATED(Items[ListPrice]))

 

q5.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

I created two tables with the dummy data below:

 

q4.PNG

We can create a calculated column below in Sales table:

 

ListPrice = IF(ISBLANK(RELATED(Items[ListPrice])),CALCULATE(MAX('Items'[ListPrice]),FILTER('Items','Items'[Country_Item]="us_P123")),RELATED(Items[ListPrice]))

 

q5.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
vanessafvg
Super User
Super User

@Anonymous

measure =
IF (
ISBLANK ( RELATED ( items[listprice] ) ),
sales[listprice],
items[listprice]
)

haven't tested it but could work?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




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.