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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Nedd help with measure (Last 24 hours count)

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 REPLY 1
Anonymous
Not applicable


@Anonymous wrote:

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


The table structure you should probably have is this:

Task Name | Task Date | Task Time | Task Datetime (if you need this column)

 

Once you have these, you can define a measure:

[# Tasks] := DISTINCTCOUNT( Tasks[Task Name] )

When you create a pivot table and put [Task Date] on rows/columns, the measure will count the distinct names of the tasks that have this date in common.

 

Another possibility is that you just drag the Tasks[Datetime] column into a canvass and want to count the number of Tasks[Task Name] that have their Datetime within 24 hours (back in time) of the currently visible Datetime. In such a case you'd have to create a different measure:

 

[# Tasks Within 24 Hrs] :=
var __currentDatetime = SELECTEDVALUE( Tasks[Datetime] )
var __currentDatetimeMinus24Hrs = __currentDateTime - 1 -- returns the previous day at the same time
var __measure =
	 CALCULATE(
	 	[# Tasks],
	 	Tasks[Datetime] <= __currentDatetime,
	 	Tasks[Datetime] > __currentDatetimeMinus24Hrs
	 )
return
	__measure

Best

Darek

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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