Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate last hour data

Hi all,

 

I'm pretty new in Power BI, I'm seeking a solution calculate last specific hour.

As I searched on Google, Power BI has a DATEADD function can help this but this function just only support for calculate previous dates.

My data has Time field per hour and count data for each hour.

TimeCount
01/01/2018 10:00:00 PM4
01/01/2018 11:00:00 PM2
02/01/2018 12:00:00 AM2
02/01/2018 01:00:00 AM6
02/01/2018 02:00:00 AM4
02/01/2018 03:00:00 AM9
02/01/2018 04:00:00 AM0

 

Is there any DAX function support calculate last hour?

 

7 Replies

  • az38's avatar
    az38
    Icon for Community Champion rankCommunity Champion

    Anonymous 

    what is your desired result for this data sample?

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi az38 ,

       

      My desired result if last 2 hours is:

       

      TimeCountcount last 2 hours
      01/01/2018 10:00:00 PM4 
      01/01/2018 11:00:00 PM2 
      02/01/2018 12:00:00 AM24
      02/01/2018 01:00:00 AM62
      02/01/2018 02:00:00 AM42
      02/01/2018 03:00:00 AM96
      02/01/2018 04:00:00 AM04

       

      • az38's avatar
        az38
        Icon for Community Champion rankCommunity Champion

        Anonymous 

        it depends on how  you calculate count but try

        Measure = CALCULATE(SUM([Count]), FILTER(ALL('Table'), DATEDIFF('Table'[Time], SELECTEDVALUE('Table'[Time]), HOUR)=2))

         

  • v-alq-msft's avatar
    v-alq-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

     

    If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

     

    Best Regards

    Allan