Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
Help_me
Frequent 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 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 TypeBaked_Date
Chewy03/27
Grape03/27
Chunky03/27

 

Thank you!

1 ACCEPTED SOLUTION
Kedar_Pande
Super User
Super User

@Help_me 

 

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.

View solution in original post

6 REPLIES 6
Jai-Rathinavel
Super User
Super 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" )



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





v-achippa
Community Support
Community Support

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

Kedar_Pande
Super User
Super User

@Help_me 

 

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.

FBergamaschi
Super User
Super User

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

lbendlin
Super User
Super User

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...

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.