Forum Discussion
Anonymous
4 years agoNot applicable
How to compare two Rows value in same table and assign a value in a separate column based on it
Hi Team, I need help in below logic: I have three tables: Orders table (Contains 1 row per orders placed with customer and revenue data as whole) Order line items table (Contains brief Orde...
- 4 years ago
Anonymous
Please useColumn = VAR Brand = CALCULATE ( SELECTEDVALUE ( 'Order Line Items'[Brand] ) ) RETURN IF ( ISBLANK ( Brand ), "Mixed Order", Brand )
tamerj1
Community Champion
4 years agoGreat Anonymous
Please use
Calculated Brand Column =
IF (
COUNTROWS ( RELATEDTABLE ( 'Order Line Items' ) ) = 1,
CALCULATE ( VALUES ( 'Order Line Items'[Brand] ) ),
"Mixed Order"
)
Anonymous
4 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.