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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Syndicate_Admin
Administrator
Administrator

Filter table between yesterday at 6 AM and today at 6AM

Hello

I need to know how to filter a table with the date and time values of yesterday at 6AM, and today at 6AM (three work shifts).

Thank you!

Xavi

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

Hi @Syndicate_Admin ,

 

Please try to create a measure:

Flag = 
var _start= CONVERT( TODAY()-1 &" "&TIME(6,0,0),DATETIME)
var _end= CONVERT( TODAY() &" "&TIME(6,0,0),DATETIME)
return IF(MAX('Table'[DateTime])>=_start && MAX('Table'[DateTime])<_end,1,0)

Apply it to visual-level filter, set as "is 1", the final output is shown below: 

Eyelyn9_0-1650868817052.png


Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

Please try to create a measure:

Flag = 
var _start= CONVERT( TODAY()-1 &" "&TIME(6,0,0),DATETIME)
var _end= CONVERT( TODAY() &" "&TIME(6,0,0),DATETIME)
return IF(MAX('Table'[DateTime])>=_start && MAX('Table'[DateTime])<_end,1,0)

Apply it to visual-level filter, set as "is 1", the final output is shown below: 

Eyelyn9_0-1650868817052.png


Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Coriel-11
Resolver II
Resolver II

You could try doing this in Power Query with separate date and time columns, and then add a column with the following complicated "If" statement:

if DateTime.Date(DateTime.FixedLocalNow()) > Date.From(Number.From([Date])+1) then 0 else
if DateTime.Date(DateTime.FixedLocalNow()) > Date.From(Number.From([Date])) and [Time] > Time.From(#datetime(1900,01,01,06,00,00)) then 1 else
if DateTime.Date(DateTime.FixedLocalNow()) > Date.From(Number.From([Date])) and [Time] <= Time.From(#datetime(1900,01,01,06,00,00)) then 0 else
if DateTime.Date(DateTime.FixedLocalNow()) = DateTime.Date([Date]) and [Time] > Time.From(#datetime(1900,01,01,06,00,00)) then 0 else 
if DateTime.Date(DateTime.FixedLocalNow()) = DateTime.Date([Date]) and [Time] <= Time.From(#datetime(1900,01,01,06,00,00)) then 1 else 
"error"

Then in the Power BI report, filter the 1s.

 

Matt

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors