Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Count for last 24 hours

Hello,   I want to make a measurement that allows me to count the names of tasks like indicating on the red column using the second blue column named DateTime as a filter, indeed the data I want to...
  • copykai's avatar
    7 years ago

    Hi Hicham,

    I have a solution that you can try.
    You need to create a calculated column next to your date time. You can call it Hours ago.

    It should look like this:

     

    Hours ago = 
    /*Years*/
    (YEAR(NOW())-YEAR('Date'[Date]))*8760 +
    /*Month*/
        (MONTH(NOW())-MONTH('Date'[Date]))*720 + 
    /*Days*/
            (DAY(NOW()) - DAY('Date'[Date]))*24 + 
    /*Hours*/
                HOUR(NOW())-HOUR('Date'[Date])

    This will calculate the numbers of hours since todays date and time.
    Of course you should switch the 'Date'[Date] with your datetime column unless you have a data model with a date table as well.

    Then simply add this Hours ago column to the visual that contains your count measure.

    If you don't have a count measure it could look like this:

    No. of names := CALCULATE(DISTINCTCOUNT('Yourtablename'[Name Tasks]))

     

    Best regards

    Kaj