This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreGet Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.
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 for Cookie_type "Chewy" and "Chunky", then "Eat", otherwise "do not eat". I added the "Grape" value to show that there are other values in the dataset that are not relevant.
| Cookie Type | Baked_Date |
| Chewy | 03/27 |
| Grape | 03/27 |
| Chunky | 03/27 |
Thank you!
Solved! Go to Solution.
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.
@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" )
Proud to be a Super User! | |
Hi @Help_me,
Thank you for reaching out to Microsoft Fabric Community.
Thank you @lbendlin, @FBergamaschi and @Kedar_Pande for the prompt response.
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa
Hi @Help_me,
We wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa
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.
Hi @Help_me
please provide more sample rows and clarify what @lbendlin asked: do you need to create a column in the table or a measure for a visual?
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
How can I write the IF statement in DAX
write to where? A calculated column? A measure?
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.