Forum Discussion

georgec96's avatar
georgec96
Helper II
4 years ago

Time filtering

Hi everyone 

 

I have a transaction table with a few million rows and a date&time column that contains records for several days.

 

Because the data gets pulled at a random time, some of my records in the table are not a full day worth of data.

 

I am looking for a way to filter my data to only include full days records i.e. 24 hrs ( 6 AM TO 6 AM) for every day in the table.

 

Any help is much appreciated 

4 Replies

Replies have been turned off for this discussion
  • HotChilli's avatar
    HotChilli
    Community Champion

    I think you can construct a new column (adjusted day) which would be a date format (not datetime) and something like:

    if hour is less than 6 then subtract 1 day from the date of date&time column else date of date&time

    • georgec96's avatar
      georgec96
      Helper II

      Any idea how to go about writing that formula in Power Query?


      I just started working in Power BI not long ago and I'm not that familiar with the language.

  • Hi, georgec96 

    Could you please consider sharing more details about it and posting expected result so it is clear on what needs to be implemented?  And It would be great if there is a sample file without any sesentive information here.

     

    It makes it easier to give you a solution.

    1. Sample (dummy dataset) data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

     

     

    Best Regards,
    Community Support Team _ Zeon Zheng

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

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    I agree you should split your DateTime into Date and Time columns (best practice). You could then add a custom column that returns 1 if the Date is today ( Date.From(DateTime.LocalNow()) ) and the hour is >=6, and 0 if not. You can then filter away the 1s.

    Pat