Forum Discussion

RKM's avatar
RKM
Helper IV
5 years ago
Solved

Check If a date is between two dates from a different table

Hi There,

This might be a very simple topic but I am struggling with DAX. Could someone please help.

I have a table [Table_CallLog] having one of it's column named 'Call_DateTime'. I have another Table [Table_DSTReference] with three columns, Year, DST_StartDateTime and DST_EndDateTime. Which gives a reference to Start and End of Daylight saving time for several years.

 

What I tried doing is..

Step 1. Added a Column [named as Year_CallLog] (In Source SQL itself) to get Year(Call_DateTime).

Step 2. Joined Table_CallLog with Table_DSTReference based on Year_CallLog to Year (Many to 1).

Step 3. (This is where I'm stuck) Trying to add a measure/calculated column in Table_CallLog, which will check

 

if(Table_CallLog.CallDateTime >=  Table_DSTReference.DST_StartDateTime && Table_CallLog.CallDateTime <  Table_DSTReference.DST_EndDateTime, "Summer", "Winter")

 

Is this correct syntax? seems I'm unable to write it that way.

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi RKM 

     

    If you want a DAX Calculated Column, connect the Year column in the two tables and use it

     

    Column = IF(Table_CallLog[Call_DateTime]>=RELATED(Table_DSTReference[DST_StartDateTime])&&Table_CallLog[Call_DateTime]<RELATED(Table_DSTReference[DST_EndDateTime]),"Summer","Winter")

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi RKM 

     

    If you want a DAX Calculated Column, connect the Year column in the two tables and use it

     

    Column = IF(Table_CallLog[Call_DateTime]>=RELATED(Table_DSTReference[DST_StartDateTime])&&Table_CallLog[Call_DateTime]<RELATED(Table_DSTReference[DST_EndDateTime]),"Summer","Winter")