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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Pikachu-Power
Impactful Individual
Impactful Individual

restrict dataset for last year

hello all,

 

i am not very familiar with the power query. in the import modus i load data from 01.01.2011, 01.02.2011... until 01.01.2021. but i want dynamicly start the load from the beginning of the last year: from 01.01.2020 until now/01.01.2021.

 

In SQL it would be:

WHERE DateFirstofTheMonth >= DATEFROMPARTS(YEAR(GETDATE())-1, 1, 1)

 

How can I do it in the Power Query?

 

Thanks

 

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

Hi, @Pikachu-Power 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Query1:

b1.png

 

You may add a new step with the following m codes.

= Table.SelectRows(#"Renamed Columns",each 
let today = DateTime.LocalNow()
in
[Date]>=#date(Date.Year(today)-1,1,1) and 
[Date]<=Date.From(today)
)

 

Result:

b2.png

 

Best Regards

Allan

 

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

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Pikachu-Power 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Query1:

b1.png

 

You may add a new step with the following m codes.

= Table.SelectRows(#"Renamed Columns",each 
let today = DateTime.LocalNow()
in
[Date]>=#date(Date.Year(today)-1,1,1) and 
[Date]<=Date.From(today)
)

 

Result:

b2.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

image.png

 

 

image.png

But how to say start from 01. 01. CurrentYear-1 ?

Say Last Year is not korrekt: Than i get only values from 2020 without 2021.

Anonymous
Not applicable

it can be done in several ways, by combining some of the features of the rich battery listed here

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Kudoed Authors