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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
asbpowerbi
Helper IV
Helper IV

Help with related column

Hi,

 

I have three tabels: Orders, ShoppingCart and Item. I have thte following realtionships:

Orders:ShoppingCart 1:M on OrderNumber

Item: ShoppingCart 1:M on ProductID

 

I am trying to set a Item.URL to a value, based on the associated value for the related order in Orders.Prefix. I am using the following code:

 


Table.AddColumn(#"Added Conditional Column1", "ThumbNailImageURL", each if RELATED('Orders'[Prefix] = "Z") then “https://www.gotaces.com” + [ImagePath] else if RELATED('Orders'[Prefix] = "A") then “https://www.asbaces.com” + [ImagePath] else null)

 

I do not have a direct realtionship between the Orders table and the Item Table. Any ideas on why this is not working for me?

 

Cheers!

 

Peter

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@asbpowerbi first the code you are showing is an M code, not DAX, so you need to add a column using DAX in the shoppingcard table

 

ThumbNailImageURL=  if RELATED('Orders'[Prefix] = "Z") then “https://www.gotaces.com” + RELATED(Item[ImagePath]) else if RELATED('Orders'[Prefix] = "A") then “https://www.asbaces.com” + RELATED(Item[ImagePath]) else null)

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤️



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@asbpowerbi already in my reply.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@asbpowerbi first the code you are showing is an M code, not DAX, so you need to add a column using DAX in the shoppingcard table

 

ThumbNailImageURL=  if RELATED('Orders'[Prefix] = "Z") then “https://www.gotaces.com” + RELATED(Item[ImagePath]) else if RELATED('Orders'[Prefix] = "A") then “https://www.asbaces.com” + RELATED(Item[ImagePath]) else null)

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤️



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks for the quick reply. What would the DAX code look like?

Hi,

 

  The solution that worked for me was to pur the measure in the ShoppingCart table rather than the Item table. I beleive that is because with I used the Related term in the Item tabale, it did not know which ShoppingCart entry was being referred to as was suggested. I did not understand the imapct of a 1:M relationship.

 

Cheers!

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.