cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hicham
Helper III
Helper III

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 visualize are the data of the last 24 hours. thank you for your help.  So, as is shown in the picture the result will be 4.

 

Capture99.PNG

 

My best regards. Thank you :). 

1 ACCEPTED SOLUTION
copykai
Resolver I
Resolver I

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]))

Untitled.png

 

Best regards

Kaj

View solution in original post

1 REPLY 1
copykai
Resolver I
Resolver I

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]))

Untitled.png

 

Best regards

Kaj

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.