Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Average basis hour duration from timestamp

Hi All   I have data with timestamp like below with single instance for each hour of day/date and i want to calculate average value for last 40 hours for each instance/hour. Any helps will be appre...
  • JarroVGIT's avatar
    6 years ago

    Took me longer than I would like to admit 😛 Anyway, I solved it, by creating a calculated column with the following formula:

    Last48Hours = AVERAGEX(FILTER(Table1, Table1[Timestamp] <= EARLIER(Table1[Timestamp]) && Table1[Timestamp] > EARLIER(Table1[Timestamp])-40/24), Table1[Value])

    The reason it took me longer than I expected was both 'how to add hours to a datetime'  and also the double filter. Anyway, this will result in the following table:

    This was fun, hope it helped 🙂

    Kind regards

    Djerro123

    -------------------------------

    If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

    Kudo's are welcome 🙂