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
jitpbi
Post Patron
Post Patron

load data for specific time duration

Hi,

 

In my dataset, I am having a field "DateTime" (format: 9/8/2020 12:00:00 AM). I want to load the data from the source only for the time in between 10:00:00 AM to 04:00:00 PM only.

Please suggest how to achieve this.

 

Thanks

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

Hi @jitpbi ,

 

If your data source is from database, you could write T-SQL to restrict data while connecting. For other data sources, it is not supported to restrict when we load data.  You could import it firstly and then filter in Query Editor.  For this situation, @Jimmy801 's answer is a good solution.

v-xuding-msft_0-1599708177554.png

 

Best Regards,
Xue Ding
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-xuding-msft
Community Support
Community Support

Hi @jitpbi ,

 

If your data source is from database, you could write T-SQL to restrict data while connecting. For other data sources, it is not supported to restrict when we load data.  You could import it firstly and then filter in Query Editor.  For this situation, @Jimmy801 's answer is a good solution.

v-xuding-msft_0-1599708177554.png

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Jimmy801
Community Champion
Community Champion

Hello @jitpbi 

 

use Table.SelectRows where you apply a Time.From to your DateTime-Column and compare it twice to the wanted timeframe

Check out this code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstS30DcyMDJQMDSyMjAAIgVHX6VYHSQJcxziZlDxAJi4oQHUJEMkHbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DateTime = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateTime", type datetime, "en-us"}}),
    SelectRowsWithinTimeFrame = Table.SelectRows
    (
        #"Changed Type",
        each Time.From(_[DateTime]) <= #time(16,0,0) and Time.From(_[DateTime]) >= #time(10,0,0) 
    )
in
    SelectRowsWithinTimeFrame

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

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.

Top Solution Authors
Top Kudoed Authors