Forum Discussion

DBC01's avatar
DBC01
Regular Visitor
1 year ago
Solved

Switch value between dates

Hi All,   I currently have the column Dax script in a custom column. Depending on the date within the 'Service_expiry_date' column it will return the status of the service ("expired", "expiring wit...
  • Kedar_Pande's avatar
    1 year ago

    DBC01 
    You can try:

    Cert status = 
    VAR _today = TODAY()
    VAR _fiveDaysAgo = _today - 5
    VAR _date = EDATE(_today, 1) - 1
    RETURN
    SWITCH(
    TRUE(),
    [service_expiry_date] > _fiveDaysAgo && [service_expiry_date] <= _today, "Test expired within last 5 days",
    [service_expiry_date] <= _fiveDaysAgo, "Test expired",
    [service_expiry_date] <= _date, "Test Expiring within 1 month",
    [service_expiry_date] > _date, "Test not yet due",
    "Check data" -- This is a catch-all for any unexpected results
    )