Forum Discussion

ben-t's avatar
ben-t
Frequent Visitor
5 years ago
Solved

How to reference date column in measure

  I'm trying to calculate the difference between 2 date/times.  But if the field is blank, i want it to reference the earliest & last dates in the slicer    I have a seperate measure that already...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi ben-t ,

     

    This error is because in the measure, you cannot write the field directly. You need to use MAX or MIN to get the current row of the field.

     

    Try to add MAX/MIN in the error field of the red curve.

    Hrs measure =
    DATEDIFF (
        IF (
            ISBLANK ( MAX ( 'MachAvail'[ACTSTART] ) ),
            [Min Date],
            MAX ( ' MachAvail'[ACTSTART] )
        ),
        IF (
            ISBLANK ( MAX ( 'MachAvail'[ACTFINISH] ) ),
            [Max Date],
            MAX ( 'MachAvail'[ACTFINISH] )
        ),
        SECOND
    )
    

     

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.