Forum Discussion

colettb's avatar
colettb
Icon for Helper I rankHelper I
1 year ago
Solved

What is wrong with this formula?

HI Community!   I am trying to create a measure that compares 2 dates together to determine whether it should be flagged as a 0 or 1.     IncludeDate = IF(NOT ISBLANK([EDC Go-Live]), IF([EDC Go...
  • Shravan133's avatar
    1 year ago

    you're trying to reference a column in a measure, but you're doing it in a row context-dependent way that doesn't work properly in a measure (which evaluates in filter context).

    Use a Calculated Column if you need row-by-row evaluation

    IncludeDate =

    IF(

        NOT ISBLANK('YourTable'[EDC Go-Live]),

        IF('YourTable'[EDC Go-Live] >= 'YourTable'[First Date to Include], 1, 0),

        BLANK()

    )

     

    Use a Measure only if aggregating (e.g., MIN, MAX, FIRSTDATE)

    IncludeDateMeasure =

    VAR EDCDate = SELECTEDVALUE('YourTable'[EDC Go-Live])

    VAR FirstDate = SELECTEDVALUE('YourTable'[First Date to Include])

    RETURN

    IF(

        NOT ISBLANK(EDCDate),

        IF(EDCDate >= FirstDate, 1, 0),

        BLANK()

    )

    This works only if a single value is in context (e.g., when filtering by row in a visual or drillthrough).