Forum Discussion
Conditional Column based on Matching Column in another Table
- 5 years ago
Hi, mpribadi07
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table1:
Table2:
Relationship(Many to Many):
You may create a calculated column as below.
Result Column = var wic = [WIC] return IF( [Ship To]="DC 04", "DOT COM", CONCATENATEX( FILTER( Table1, [WIC]=wic ), [Opstudy], "," ) )Result:
Or you may try the following calculated table.
Table = ADDCOLUMNS( SUMMARIZE( Table2, Table2[WIC], "Ship To", CONCATENATEX( Table2, [Ship To], "," ) ), "Result", var wic = [WIC] return IF( [Ship To]="DC 04", "DOT COM", CONCATENATEX( FILTER( Table1, [WIC]=wic ), [Opstudy], "," ) ) )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi mpribadi07
Assuming the tables have a (1-1) relationship, this code creates a column in Table2
ToResult = IF('Table2'[Ship To] = "DC 04" , "DOT COM", RELATED(Table1[Opstudy]))
regards
Phil
- mpribadi075 years agoRegular Visitor
Hi Phil,
Thank you so much for your reply!
The Tables have a many to many relationship.
I will try the code you provided but appreciate any insights if you think the code won't work for a many to many relationship.
Thank you!
Marsha