Forum Discussion
How to compare two Rows value in same table and assign a value in a separate column based on it
- 4 years ago
Anonymous
Please useColumn = VAR Brand = CALCULATE ( SELECTEDVALUE ( 'Order Line Items'[Brand] ) ) RETURN IF ( ISBLANK ( Brand ), "Mixed Order", Brand )
Hi tamerj1 ,
It is still only giving all values as "Mixed Order". Please see the screenshot below:
Can we compare orders column with Brand column, like if One Order is having multiple brand purchased together it returns "Mixed Order" else "Brand"?
Anonymous
Can you please create a column
COUNTROWS ( RELATEDTABLE ( 'Order Line Items' ) )and let me know what results you get
- Anonymous4 years agoNot applicable
- tamerj14 years agoCommunity Champion
Great Anonymous
Please use
Calculated Brand Column = IF ( COUNTROWS ( RELATEDTABLE ( 'Order Line Items' ) ) = 1, CALCULATE ( VALUES ( 'Order Line Items'[Brand] ) ), "Mixed Order" )- Anonymous4 years agoNot applicable
Hi tamerj1 ,
Thanks, above logic is working correctly to some extent but the result is still not accurate.
currently it is giving result as (if the order line item count is 1, then it is giving brand name) but in my case order can have multiple productsof brands in it but we need to see if the products in one order are of same Brand or not
For eg:
Scenario 1:
Order Line Items Table Order No Product SKU Product SKU Code Brand 67890012 Hair Conditioner - 340 ml 15 Matrix 67890012 Hair Serum - 400ml 12 Matrix Expected Brand Column result:
Order Table Order No Customer Revenue Calculated Brand Column 67890012 Customer A 540 Matrix Brand Scenario 2:
Order Line Items Table Order No Product SKU Product SKU Code Brand 67894677 Shampoo - 340 ml 13 Pantene 67894677 Hair Conditioner - 340 ml 11 Sunsilk 67894677 Hair Serum - 400ml 12 Matrix Expected Brand Column result:
Order Table Order No Customer Revenue Calculated Brand Column 67894677 Customer A 580 Mix Brand This is what I am looking for to create. Please help me.