Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.