Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Offset 22 hours

Hi! How can I use DAX to offset 22 hours from data?

Thanks in advance!

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Anonymous ,

    I created some data:

    Here are the steps you can follow:

    1. Create measure.

    Falg =
    var _22hours=NOW()-22/24
    var _maxtime=MAXX(FILTER(ALL('Table'),HOUR([date])=HOUR(_22hours)&&DAY([date])=DAY(_22hours)),[date])
    return
    IF(MAX('Table'[date])=_maxtime,1,0)

    2. Place [Flag] in Filter, set is =1, apply filter.

    3. Result:

     

    Best Regards,

    Liu Yang

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

3 Replies

  • Anonymous , Can explain with example ?

     

    If you need add time 

     

    New column = [Datetime] +time(22,0,0)

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi amitchandak, thanks for responding.

    I have a report that captures the latest record everytime it refreshes. What I need to do is to display the previous shift. It only gets viewed twice a day - once per shift, 5AM/5PM. Say, at 5PM today, I need to display the last record from 7PM the previous day where if it's 5AM, I need to display the last record from 7AM the previous day.

     

    An alternative is to ensure that it's only refreshed with the database twice a day, maybe at 4:30 so that it's ready by 5. But I am wondering if there's a way that I could do it in DAX or Power Query.

     

    Thank you!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    I created some data:

    Here are the steps you can follow:

    1. Create measure.

    Falg =
    var _22hours=NOW()-22/24
    var _maxtime=MAXX(FILTER(ALL('Table'),HOUR([date])=HOUR(_22hours)&&DAY([date])=DAY(_22hours)),[date])
    return
    IF(MAX('Table'[date])=_maxtime,1,0)

    2. Place [Flag] in Filter, set is =1, apply filter.

    3. Result:

     

    Best Regards,

    Liu Yang

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