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
Anonymous
Not applicable

Pass the Dynamic Year value to parameters in Power Query

Hi All,

I have a report with a bar chart to show the Sales values for 3 consequent years.

 

Now we are in the year 2023. I should show 2023,2022 and 2021 values in the bar chart. 

 

At this moment, I am passing the year parameter 2021 value manually. How to pass this value dynamically?

 

I have seen query options (in the attached image) from this link but don't know how to enable them.

 

https://learn.microsoft.com/en-us/power-query/power-query-query-parameters

 

 

Please help me.

parameters-query.png

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Do you have a Year column in your table and you are using the Year column to filter rows in years 2023,2022 and 2021? If so, you can first filter rows by Year column to select rows greater than or equal to 2021. You will get an M code generated in the formula bar. Then replace 2021 with Date.Year(DateTime.LocalNow()) - 2. This will return the year value based on your system datetime dynamically. 

vjingzhang_0-1680060019137.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Do you have a Year column in your table and you are using the Year column to filter rows in years 2023,2022 and 2021? If so, you can first filter rows by Year column to select rows greater than or equal to 2021. You will get an M code generated in the formula bar. Then replace 2021 with Date.Year(DateTime.LocalNow()) - 2. This will return the year value based on your system datetime dynamically. 

vjingzhang_0-1680060019137.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

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