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
dyabes
Helper I
Helper I

RELATED/RELATEDTABLE with condition

I have two tables (1) Order Details (Date, SKU, Units Sold) and (2) Cost (SKU, Unit Cost, Year).

 

I need to bring in Unit Cost to my Order Details table so I can get my COGS. But I also need to evaluate which cost to apply based on the Year. The Cost table is a updated every year and new rows are added.

 

Any help will be much appreciated.

 

Cheers,

David

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

In the Order Details Table, create a calculated column to extract Year from the Date: Year = YEAR('Order Details'[Date]).  Assuming every Year and SKU record in the Cost Table is a unique combination, try this calculated column formula in the Order Details Table

=LOOKUPVALUE('Cost'[Unit Cost],'Cost'[SKU],[SKU],'Cost'[Year],[Year])

This formula should work without creating any relationship betwenn the 2 Tables.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

In the Order Details Table, create a calculated column to extract Year from the Date: Year = YEAR('Order Details'[Date]).  Assuming every Year and SKU record in the Cost Table is a unique combination, try this calculated column formula in the Order Details Table

=LOOKUPVALUE('Cost'[Unit Cost],'Cost'[SKU],[SKU],'Cost'[Year],[Year])

This formula should work without creating any relationship betwenn the 2 Tables.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

If the latest Cost values are still not available, how do I nest the LOOKUPVALUE to return the latest value available?

Please have the basic courtesy to thank me for helping you in the first place - it is just basic etiquettes.  For your second question, share both datasets (in a format that i can paste them in an Excel file) and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I have no excuse. Please accept my sincerest apology. Will not happen again. 

No problem - Thank you.  Please share the datasets requested for in my previous message - I hope i can help.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.