Forum Discussion
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
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! ❤️
4 Replies
- parry2kSuper 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! ❤️
- asbpowerbiHelper IV
Thanks for the quick reply. What would the DAX code look like?
- asbpowerbiHelper IV
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!
- parry2kSuper User
asbpowerbi already in my reply.