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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.