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
RaphaelAlves
Frequent Visitor

Filter by Today’s date in Power Query

I need to filter by today date. There is a colunm with some dates where I’d like to filter only the today’s date. How to do it? Thanks!
2 ACCEPTED SOLUTIONS

Hi @RaphaelAlves ,
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

 

 

= Table.SelectRows(#"Name of Previous Step", each [Column1] = DateTime.LocalNow())

Technically it returns a Date/Time value, where TODAY() returns a Date value. The literal closest to TODAY() is Date.From(DateTime.LocalNow()) which you should use rather than DateTime.LocalNow() alone if the column you're filtering is already a plain date type rather than date/time.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Hi @RaphaelAlves ,

 

If your data is date type not date/time one, Then we should use DateTime.Date(DateTime.LocalNow()) to work on it.

 

Capture.PNG

 

Btw, M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNQ3NNA3MlaK1YFxDYEIwTUwBCJUrpFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [DATE = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DATE", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([DATE] = DateTime.Date(DateTime.LocalNow())))
in
    #"Filtered Rows"
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

12 REPLIES 12
Syndicate_Admin
Administrator
Administrator

I was trying to do something similar and the logic or syntax may apply.  I was trying to limit my TCdate (timecard date) to any date prior to today.  I used this in Power Query and it worked:  = Table.SelectRows(#"Filtered Rows", each [TCdate] < List.Max(#"Filtered Rows"[TCdate]))

Nathaniel_C
Super User
Super User

Hi @RaphaelAlves ,
Just click on the top of the column on the down arrow, your filter selection will come up.  Choose there.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
filter date.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi Nathaniel,

It does not works... I’m connecting to an ODS table, so this colunm is filled out automatically automatically with a new date. I need to filter to show only the current date.

Hi @RaphaelAlves ,

 

Tell me what an ODS table is? It sounds like you are trying to filter before it gets to Power Query. Is that right? If so I cannot help you. If that is the case you would be better off to post again, and describe that.


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I need to do the filter using the power Query. Forget about the OSD, it’s just a table where the data comes from. The Column with dates are filled daily with new dates. I just need to filter to show only the today’s date.
Something lile that: [DateColunm]=today()

Hi
I could configure it using DAX in power BI, but my table is too big making it slow, so my intention is to filter it before applying to power BI. Let me know if you may help me, thanks mate!

Hi @RaphaelAlves ,
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

 

 

= Table.SelectRows(#"Name of Previous Step", each [Column1] = DateTime.LocalNow())

Technically it returns a Date/Time value, where TODAY() returns a Date value. The literal closest to TODAY() is Date.From(DateTime.LocalNow()) which you should use rather than DateTime.LocalNow() alone if the column you're filtering is already a plain date type rather than date/time.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks, I will try soon this solution and let you know if it’s ok.

Hi @RaphaelAlves ,

 

If your data is date type not date/time one, Then we should use DateTime.Date(DateTime.LocalNow()) to work on it.

 

Capture.PNG

 

Btw, M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNQ3NNA3MlaK1YFxDYEIwTUwBCJUrpFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [DATE = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DATE", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([DATE] = DateTime.Date(DateTime.LocalNow())))
in
    #"Filtered Rows"
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

And I just say that because of how the forum works.Smiley Wink





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi Nathaniel ... I am not sure if this is the right thread for my questoin .. .but perhaps you can help? When I get data into Power BI I see that the date created date is based on some other time zone ... in my case about 9 hours behind .. which means when 'getting data' I can't use the Date Created filter as the times are not correct. 

 

Can you tell me how to set this to my particular time zone?

 

thanks

Marc

Hey @MarcUrdang ,
If I understand your question, here is a good video that will take you through the steps Ruth at Curbal 
Thank you,


Let me know if you have any questions.






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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