cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seroskij Frequent Visitor
Frequent Visitor

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

Accepted Solutions
Highlighted
Moderator v-qiuyu-msft
Moderator

Re: Lookup in Diff Table if No Match then Default Value

Hi @seroskij,

 

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
vanessafvg Super Contributor
Super Contributor

Re: Lookup in Diff Table if No Match then Default Value

@seroskij

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

haven't tested it but could work?


Did I answer your question? Mark my post as a solution.
Proud a to be a Datanaut!
Highlighted
Moderator v-qiuyu-msft
Moderator

Re: Lookup in Diff Table if No Match then Default Value

Hi @seroskij,

 

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

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 61 members 1,489 guests
Please welcome our newest community members: