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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
mmace1
Impactful Individual
Impactful Individual

How to reference the result of this M code, in a Parameter?

I want to automatically limit my table loads to Jan 1st of 3 years ago. 

 

I wrote this code, to give me Jan 1st of 3 years ago. I'd like that (automatically-updating) result to then filter my table loads. 

= Date.StartOfYear(Date.AddYears(Date.From(DateTime.LocalNow()),-3))

 

And it gives the proper result. 

Capture.PNG

 

My next step is to create a parameter that = the output above.  Then I can filter by the parameter.  But when I select 'Query' as the suggested value for the parameter, it doesn't show the above query as an option

mmace1_0-1613596461955.png

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

@mmace1 , query used for parameter must be a list query, that's to say, the query evaluates to a list; therefore simply enclose your M code with {} to make it a list,

= {Date.StartOfYear(Date.AddYears(Date.From(DateTime.LocalNow()),-3))}

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

@mmace1 , query used for parameter must be a list query, that's to say, the query evaluates to a list; therefore simply enclose your M code with {} to make it a list,

= {Date.StartOfYear(Date.AddYears(Date.From(DateTime.LocalNow()),-3))}

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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