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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.