Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

DAX Function To Compare 3 Different Dates-Timestamps Columns

Hi,

 

Am using Powerpivot and I have 3 columns, each with date & time scans in them. The 3 columns occur in the exact sequence as shown below: (i.e. Job booking date occurs first, then Attempted Acceptance Date, then Acceptance Date)

 

  1. Job Booking Date
  2. Attempted Acceptance Date
  3. Acceptance Date

I have a calculated column called BEFORE 12 SCAN and I need a function to determine the following logic:

 

if Job Booking Date < 12:00 midday, AND Attempted Acceptance Date < 12:00 midday (on the same day) AND Acceptance Date < 12:00 midday (on the same day), then output "YES", else "NO" in BEFORE 12 SCAN column

 

Note: Job booking has NO blank cells but Attempted Acceptance Date and Acceptance Date may have blank cells.

 

 

Appreciate any help:)

 

  • Anonymous's avatar
    Anonymous
    7 years ago

    Yes that worked and powerpivot does include = at beginning by default. 

    Sorry its my first time seeing such a long formula and didn't know you could include variables in a formula which is awesome.

     

    Thank you again for your help, much appreciated:)

  • Anonymous's avatar
    Anonymous
    7 years ago

    AlB  its ok I've managed to fix issue myself after some manual testing. Thanks again:)

12 Replies

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

    Hi Anonymous 

    Try this

    NewCol = 
    VAR Time1_ = HOUR(Table1[Job Booking Date])
    VAR Time2_ = HOUR(Table1[Attempted Acceptance Date])
    VAR Time3_ = HOUR(Table1[Acceptance Date])
    VAR Date1_ = INT(Table1[Job Booking Date])
    VAR Date2_ = INT(Table1[Attempted Acceptance Date])
    VAR Date3_ = INT(Table1[Acceptance Date])
    VAR SameDate_ = (Date1_ = Date2_) &&  (Date2_ = Date3_)
    RETURN
    IF( SameDate_ && Time1_ < 12 && Time2_ < 12  && Time3_ < 12, "Yes", "No")

    Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

    Cheers  Datanaut

    • Anonymous's avatar
      Anonymous
      Not applicable

      AlB  thank you for the quick reply. FYI am using powerpivot in Excel. Your formula structure/syntax looks different, will it still work or do I have to modify it before applying it??

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

        Should be the same. The DAX engine is the same in both cases