Forum Discussion

PrakashPalle's avatar
PrakashPalle
Icon for Helper II rankHelper II
2 years ago
Solved

Condition based on date time field fall between two date time columns

Hi Power BI Experts, I want to calculate condition column based on the date time field will fall in between, before & after conditions. Sample data below. Expected output in "condition" column. Plea...
  • dulan_kavinda's avatar
    2 years ago

    Right click on the table and add "New Column". Use below DAX (Modify the table name).

     

    Condition =
    VAR DateTimeValue = 'Table_name'[Date Time]
    VAR FromDateTimeValue = 'Table_name'[From Date Time]
    VAR ToDateTimeValue = 'Table_name'[To Date Time]
    RETURN
    SWITCH(
    TRUE(),
    DateTimeValue >= FromDateTimeValue && DateTimeValue <= ToDateTimeValue, "With In Range",
    DateTimeValue < FromDateTimeValue, "Before Range",
    DateTimeValue > ToDateTimeValue, "After Range"
    )