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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mklevemann
Frequent Visitor

Filter by last 20 hours power query

I am trying to filter some records that have a date/time field but I only want the ones that have occurred in the last 20 hours.   Any idea on how I can filter that in power query?  Thanks.

1 ACCEPTED SOLUTION
MasonMA
Community Champion
Community Champion

Hello @mklevemann 

 

Assuming your table has Timestamp or Date/time column that looks like below

MasonMA_0-1755213291767.png

 

Click 'fx' to 'Add Step', and use below M code (but remember to replace ' Source '  to the name of your previous step, my last step in below picture is ' #"Changed Type" '  and [EventTimestamp] to your actual date/time Column) 

MasonMA_2-1755213716607.png

= Table.SelectRows(Source, each [EventTimestamp] >= DateTime.LocalNow() - #duration(0, 20, 0, 0))

MasonMA_3-1755213853935.png

 

Hope this helps:) 

 

View solution in original post

2 REPLIES 2
MasonMA
Community Champion
Community Champion

Hello @mklevemann 

 

Assuming your table has Timestamp or Date/time column that looks like below

MasonMA_0-1755213291767.png

 

Click 'fx' to 'Add Step', and use below M code (but remember to replace ' Source '  to the name of your previous step, my last step in below picture is ' #"Changed Type" '  and [EventTimestamp] to your actual date/time Column) 

MasonMA_2-1755213716607.png

= Table.SelectRows(Source, each [EventTimestamp] >= DateTime.LocalNow() - #duration(0, 20, 0, 0))

MasonMA_3-1755213853935.png

 

Hope this helps:) 

 

Thanks!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.