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
GilesWalker
Skilled Sharer
Skilled Sharer

Only show last 24 hours from 6am?

Hi everyone,

 

A little stumped with this one. I need to create a filter so that the data in the report on shows the last 24 hours from 6am each morning. Basically once the clock ticks over 6am I need the report to only show me everything that has happened over the 24 hours prior.

 

The tables containing the data do have timestamps but are random, none will be at 6am. I have created a DateKey table using dax formula which has all dates.

 

Hope some one has an answer to this.

 

Thanks,

 

Giles

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @GilesWalker,

 

You can use below formula to get min date, then use filter function to get the result data.

 

Measure:

 

minTime = 
var temp= NOW()
return
if(HOUR(temp)>=6,temp,DATE(YEAR(temp),MONTH(temp),DAY(temp)-1)+TIME(6,MINUTE(temp),SECOND(temp)))

 

Table formula:

 

 

New Table= FILTER(ALL(TABLE),[Date]>=[minTime]&&[Date]<=Now())

 

Result sample:

 

1.

Now:  1/6/2017 15:00

Date Range: 1/6/2017 6:00 ~ 1/6/2017 15:00

 

2.

Now:  1/6/2017 5:00

Date Range: 1/5/2017 6:00 ~ 1/6/2017 5:00

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @GilesWalker,

 

You can use below formula to get min date, then use filter function to get the result data.

 

Measure:

 

minTime = 
var temp= NOW()
return
if(HOUR(temp)>=6,temp,DATE(YEAR(temp),MONTH(temp),DAY(temp)-1)+TIME(6,MINUTE(temp),SECOND(temp)))

 

Table formula:

 

 

New Table= FILTER(ALL(TABLE),[Date]>=[minTime]&&[Date]<=Now())

 

Result sample:

 

1.

Now:  1/6/2017 15:00

Date Range: 1/6/2017 6:00 ~ 1/6/2017 15:00

 

2.

Now:  1/6/2017 5:00

Date Range: 1/5/2017 6:00 ~ 1/6/2017 5:00

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

I just need the last 3 hours, you could adapt the formula to do that. help!!!

Anonymous
Not applicable

THis should explain it from start to finish.

 

TABLE = the table you sum from

COL = the colum you sum from

DATE = your date colum. 

 

3 hrs=0,125 day. 

 

European:

LAST6HRS = CALCULATE( COUNT(TABLE[COL]) ; TABLE[DATE] > NOW()-0,125  )     

 

US

 LAST6HRS = CALCULATE( COUNT(TABLE[COL]) ; TABLE[DATE] > NOW()-0.125  )     

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.