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

See when key Fabric features will launch and what’s already live, all in one place and always up to date. Explore the new Fabric roadmap

Reply
AspasiaLiz
Frequent Visitor

Convert to Parameter Greyed Out

AspasiaLiz_0-1698790225769.png

Hi, I'd like to pull Odata Web Services from Business Central - Item Ledger Entry table but I want to pull last 12 months so that it doesn't take forever to pull. I have created a table and made that into two sets of dates in text to use as a parameter so that I can pull this automatically without touching the dates every month but I just cannot make this into parameter?

 

I've also tried to create new parameter through query but they do not show up.

AspasiaLiz_1-1698790415000.png

 

How do I accomplish this? I don't want to put the dates manually every time I run this?

 

Thanks, 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @AspasiaLiz 

The "Convert to Parameter" option in the interface is only available for values that are a "simple non-structured constant" (see here).

 

In your case, if FromDate and ToDate are more complex queries, you would have to edit the code in the Advanced Editor and add appropriate metadata to turn these into parameters.

 

For example, if ToDate is defined as:

let
    TodayDate = Date.From(DateTime.FixedLocalNow()),
    DateEnd_Date = Date.EndOfMonth(Date.AddMonths(TodayDate,-1)),
    DateEnd_Text = Date.ToText(DateEnd_Date, "yyyy-MM-dd")
in
    DateEnd_Text

then you can convert it to a parameter by editing the code as follows, wrapping in brackets and adding meta [...]:

(
    let
       TodayDate = Date.From(DateTime.FixedLocalNow()),
       DateEnd_Date = Date.EndOfMonth(Date.AddMonths(TodayDate,-1)),
        DateEnd_Text = Date.ToText(DateEnd_Date, "yyyy-MM-dd")
    in
        DateEnd_Text
)
meta [IsParameterQuery=true, Type="Text", IsParameterQueryRequired=false]

I suggest specifying IsParameterQueryRequired = false otherwise the interface shows an error in certain places.

 

As a side note, if another query is referencing FromDate or ToDate, it shouldn't matter whether or not they are parameters, as the value will still be the same.

 

See Ben Gribaudo's blog for more detail on metadata:

https://bengribaudo.com/blog/2021/03/17/5523/power-query-m-primer-part20-metadata

 

Does the above help with what you're doing?

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

5 REPLIES 5
AspasiaLiz
Frequent Visitor

Thanks so much! Mine is derived from a query in a table in excel so that the user possibly change the date if needed-  then was into a text in the end. In the end it was just a text form and thought that is not complex anymore. So although the end result is just a text,  it doesn't allow it to be parameter and the parameter can only o be purely from PQ itself?

 

Thanks,

AspasiaLiz_0-1698844034709.png

 

You're welcome 🙂

Thanks for the additional info.
The key thing is that the interface is set up so that "Convert to Parameter" option is only enabled for "literal" values, i.e. hard-coded numbers, date, text etc.

 

Even if the result of your query is a single text value, if it is not a literal text value, "Convert to Parameter" is not available.

 

So the only way to create a dynamic parameter is to add the metadata as I showed in the previous post.


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Thanks for the clarification!

OwenAuger
Super User
Super User

Hi @AspasiaLiz 

The "Convert to Parameter" option in the interface is only available for values that are a "simple non-structured constant" (see here).

 

In your case, if FromDate and ToDate are more complex queries, you would have to edit the code in the Advanced Editor and add appropriate metadata to turn these into parameters.

 

For example, if ToDate is defined as:

let
    TodayDate = Date.From(DateTime.FixedLocalNow()),
    DateEnd_Date = Date.EndOfMonth(Date.AddMonths(TodayDate,-1)),
    DateEnd_Text = Date.ToText(DateEnd_Date, "yyyy-MM-dd")
in
    DateEnd_Text

then you can convert it to a parameter by editing the code as follows, wrapping in brackets and adding meta [...]:

(
    let
       TodayDate = Date.From(DateTime.FixedLocalNow()),
       DateEnd_Date = Date.EndOfMonth(Date.AddMonths(TodayDate,-1)),
        DateEnd_Text = Date.ToText(DateEnd_Date, "yyyy-MM-dd")
    in
        DateEnd_Text
)
meta [IsParameterQuery=true, Type="Text", IsParameterQueryRequired=false]

I suggest specifying IsParameterQueryRequired = false otherwise the interface shows an error in certain places.

 

As a side note, if another query is referencing FromDate or ToDate, it shouldn't matter whether or not they are parameters, as the value will still be the same.

 

See Ben Gribaudo's blog for more detail on metadata:

https://bengribaudo.com/blog/2021/03/17/5523/power-query-m-primer-part20-metadata

 

Does the above help with what you're doing?

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

This is fantatsic solution.

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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

Top Solution Authors
Top Kudoed Authors