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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BillyT_350
Helper V
Helper V

"Last X Calendar Years" filter for Dynamics API pull

I have a report that pulls a HUGE set of data from Dynamics API. In order to conrtol the size of this data, I would like to limit the data pulls to the past year and this year. This is not to be hard-coded, but rather dynamic so that as the years change so will the data pull.

 

If you were to code this in SQL, it would look like this: 

WHERE DATE >= '1-1-' || (YEAR(CURRENT DATE) - 1)

 

The closest thing that I've found is to use the filtering functionality in the query editor, but you can only use "Last X Years", "Last X Months", etc. I need to be able to specify Calender Year, as you would with the relative date slicer.

 

I was think it may be codeable. Take the following Filtered Rows query step:

= Table.SelectRows(#"Removed Columns"
, each Date.IsInPreviousNYears([createdon], 2)
)

 

Unfortunately, it's not as simple as changing: 

= Table.SelectRows(#"Removed Columns"
, each Date.IsInPreviousNCalendarYears([createdon], 2)
)

 

Does anyone know any solutions? Thanks!

1 REPLY 1
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @BillyT_350

 

Here is the reference for you.

https://excel.city/2015/09/relative-dates-and-periods-in-power-query/

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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 Solution Authors
Top Kudoed Authors