Forum Discussion

am_i_really's avatar
am_i_really
Frequent Visitor
3 years ago
Solved

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!

 

  • 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

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity 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

     

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        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