Forum Discussion
akp
8 months agoFrequent Visitor
Lookup for a value and compare DAX
Hi all, I have a sample table like below with multiple rows for each Order. I am trying to check for an Order with specific discount category value of ABC, for the same Order if there is a row ent...
- 8 months ago
Use a calculated column that checks “does this Order have DEF = TRUE?”, and only returns Yes on the ABC row.
Calculated Eligibility = VAR ThisOrder = 'Table'[Order] VAR HasDefTrue = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table' ), 'Table'[Order] = ThisOrder && 'Table'[discount category] = "DEF" && 'Table'[Discount Eligibility] = TRUE () ) ) > 0 RETURN IF ( 'Table'[discount category] = "ABC" && HasDefTrue, "Yes", "n/a" )
cengizhanarslan
Super User
8 months agoUse a calculated column that checks “does this Order have DEF = TRUE?”, and only returns Yes on the ABC row.
Calculated Eligibility =
VAR ThisOrder = 'Table'[Order]
VAR HasDefTrue =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
ALL ( 'Table' ),
'Table'[Order] = ThisOrder
&& 'Table'[discount category] = "DEF"
&& 'Table'[Discount Eligibility] = TRUE ()
)
) > 0
RETURN
IF (
'Table'[discount category] = "ABC" && HasDefTrue,
"Yes",
"n/a"
)