Forum Discussion
Help_me
5 months agoFrequent Visitor
How to write this IF statement for same date, but different statuses?
Hello, I have the two columns below in the same table. "Cookie Type" is text field and "Baked_Date" is a date value. How can I write the IF statement in DAX for the concept: If the same baked_date ...
- 5 months ago
Calculated column:
Eat Flag =
VAR CurrentDate = 'Table'[Baked_Date]
RETURN
IF(
CALCULATE(
COUNTROWS('Table'),
'Table'[Baked_Date] = CurrentDate,
'Table'[Cookie Type] IN {"Chewy", "Chunky"}
) = 2,
"Eat",
"Do not eat"
)Checks if both Chewy + Chunky exist on same Baked_Date.
Jai-Rathinavel
5 months agoSuper User
Help_me I am assuming it is for a calculated column. Please try out the below dax to create the Eat Flag Column
Eat Flag Column = VAR CurrentDate = 'Table'[Baked_Date]
VAR HasChewy =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Baked_Date] = CurrentDate,
'Table'[Cookie Type] = "Chewy"
)
VAR HasChunky =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Baked_Date] = CurrentDate,
'Table'[Cookie Type] = "Chunky"
)
RETURN
IF ( HasChewy > 0 && HasChunky > 0, "Eat", "Do not eat" )