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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
yousseftb
Frequent Visitor

filter - last 14 days

Hello,

I want to filter in a table in POWER QUERY the date column to have only the data of the last 14 days.

I have tried to put the following:

 

= Table.SelectRows (_Data_sales, each [Date_Invoice]> = # DDateTime.LocalNow () - 14)

 

but it gives me error.

1 ACCEPTED SOLUTION

@yousseftb 

Looks like your column in in DateTime format. Let's convert it then. Try this:

 

= Table.SelectRows (_Data_sales, each Number.From(Date.From(DateTime.LocalNow()) - Date.From([Date_Invoice])) <=14 )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

View solution in original post

4 REPLIES 4
AlB
Super User
Super User

Hi @yousseftb 

It always helps to paste here the exact error message you get. Try this:

 

= Table.SelectRows (_Data_sales, each Number.From(Date.From(DateTime.LocalNow()) - [Date_Invoice]) <=14 )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

yousseftb
Frequent Visitor

Helo, many tanks for your message.

When I put your code I get this error:

Expression.Error: We cannot apply operator - to types Date and DateTime.

Details:

Operator=-

Left=05/06/2020

Right=07/01/2019 00:00:00

 

any suggestion ?

@yousseftb 

Looks like your column in in DateTime format. Let's convert it then. Try this:

 

= Table.SelectRows (_Data_sales, each Number.From(Date.From(DateTime.LocalNow()) - Date.From([Date_Invoice])) <=14 )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

yousseftb
Frequent Visitor

Many thanks, it s work

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors