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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
am_i_really
Frequent Visitor

IF Time DAX Measure

Hi All,

 

I'm trying to write a DAX Measure to determine how many transactions are breakfast vs lunch. This is what I have but its not working. Any idea what I'm doing wrong?

 

IF(COUNT(Master[Order Time]) < TIME(11,00,00),"Breakfast", "Lunch")
 
For any orders before 11am, I need it to say Breakfast, and anything after 11am should be Lunch.
 
Thanks in advance!

 

1 ACCEPTED SOLUTION

@am_i_really Sorry, I had some syntax errors in that, try this:

Measure Breakfast = 
  VAR __Table = 
    ADDCOLUMNS(
      'Table',
      "__Type", IF([Order Time] < TIME(11,00,00),"Breakfast", "Lunch")
    )
  VAR __Result = COUNTROWS(FILTER(__Table, [__Type] = "Breakfast"))
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@am_i_really Try below. However, this is very dependent on the format of your Order Time column, can you post an example of your data?

Measure Breakfast =
  VAR __Table = 
    ADDCOLUMNS(
      'Master',
      "__Type", IF([Order Time]) < TIME(11,00,00),"Breakfast", "Lunch")
    )
  VAR __Result = COUNTROWS(FILTER(__Table, [__Type] = "Breakfast"
RETURN
  __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

This is what my column looks like. The solution you provided didnt work.

 

am_i_really_0-1676482076523.png

 

@am_i_really Sorry, I had some syntax errors in that, try this:

Measure Breakfast = 
  VAR __Table = 
    ADDCOLUMNS(
      'Table',
      "__Type", IF([Order Time] < TIME(11,00,00),"Breakfast", "Lunch")
    )
  VAR __Result = COUNTROWS(FILTER(__Table, [__Type] = "Breakfast"))
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.