Forum Discussion

syaifulefendi's avatar
syaifulefendi
Frequent Visitor
3 years ago
Solved

ASK HELP - Getting Tolerable Shift from Date

Hi 

 

Kindly help me to get result on result column with Dax as shown below 

start time if <= 9AM , tolerable will be 9AM , beside this will be same as schedulle or Shift Start column 

 

Thanks 
SE

  • syaifulefendi 

    As a calculated column you could add it like this.

    Tolerable Late (Result) = 
    IF (
        HOUR ( 'Table'[Shift Start] ) <= 9,
        DATEVALUE ( 'Table'[Shift Start] ) + TIME ( 9, 0, 0 ),
        'Table'[Shift Start]
    )

    If you are looking for a measure it would be like this.

    Tolerable Late (Result) Measure = 
    VAR _ShiftStart = SELECTEDVALUE ( 'Table'[Shift Start] )
    RETURN
    IF ( HASONEVALUE ( 'Table'[Shift Start] ),
        IF (
            HOUR ( _ShiftStart ) <= 9,
            DATEVALUE ( _ShiftStart ) + TIME ( 9, 0, 0 ),
            _ShiftStart
        ),
        BLANK()
    )

2 Replies

  • syaifulefendi 

    As a calculated column you could add it like this.

    Tolerable Late (Result) = 
    IF (
        HOUR ( 'Table'[Shift Start] ) <= 9,
        DATEVALUE ( 'Table'[Shift Start] ) + TIME ( 9, 0, 0 ),
        'Table'[Shift Start]
    )

    If you are looking for a measure it would be like this.

    Tolerable Late (Result) Measure = 
    VAR _ShiftStart = SELECTEDVALUE ( 'Table'[Shift Start] )
    RETURN
    IF ( HASONEVALUE ( 'Table'[Shift Start] ),
        IF (
            HOUR ( _ShiftStart ) <= 9,
            DATEVALUE ( _ShiftStart ) + TIME ( 9, 0, 0 ),
            _ShiftStart
        ),
        BLANK()
    )