cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jch Regular Visitor
Regular Visitor

Query for parameter suggested values (global variable for entire project?)

We are trying to set global variables StartDate and EndDate that all queries can references as a filter.

 

I would like to set StartDate to this TSQL formula SELECT DATEADD(MONTH, -12, DATEADD(MONTH, DATEDIFF(MONTH, '19000101', GETDATE()) - 1, '19000101')) 

 

When I select Query (see screenshot below) from the Suggested Value box, it doesn't let me enter the formula into the Query box. 

 

If setting a single value in a parameter that all queries can reference is not an option, what are the other options?

 

Thanks in Advance

suggested values query.png

6 REPLIES 6
ankitpatira Super Contributor
Super Contributor

Re: Query for parameter suggested values (global variable for entire project?)

@jch Query dropdown doesn't let you write formulas there but only reference other queries. So in your model create another query that returns or contains value from your TSQL and then reference that query under Query section for Parameters.

Highlighted
jch Regular Visitor
Regular Visitor

Re: Query for parameter suggested values (global variable for entire project?)

I created a new datasource with the Global Date Parameters for reference. It still won't let me enter in anything at all in the Query dropdown box. Is there another step I need to follow?

 

Thanks in advance

 

 

Global Date Parameters.png

Moderator v-yuezhe-msft
Moderator

Re: Query for parameter suggested values (global variable for entire project?)

Hi @jch,

You can perform the following steps to populate the parameter list based on a query.

1. Import a table from SQL Server by writing your T-SQL in SQL statement(optional) textbox as shown in the following screenshot.
1.PNG

2. Get a list from the date column in the imported table,  you would need to click on the column to select it and then right-click and select “Add as New Query”. Now you have a list named Query 3 whose values are derived from your T-SQL formula.
2.PNG

3.When you create new parameter, you will be able to choose Query 3 as follows.
3.PNG


For more details about how to create query parameter in Power BI Desktop, please review the following blog.
Data-Driven Power BI Desktop Parameters Using List Queries


Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jch Regular Visitor
Regular Visitor

Re: Query for parameter suggested values (global variable for entire project?)

Thank you for the feedback, still encountering problems. I followed instructions as noted in screenshot below and the Query dropdown box still won't accept values. Is there anything else I'm missing?

 

parameters still not working.png

Moderator v-yuezhe-msft
Moderator

Re: Query for parameter suggested values (global variable for entire project?)

Hi @jch,

Based on your screenshot, you are missing the step that get a list from the date column in your table. As stated in the blog I have post, To get a list from a column in your table,  you need to click on the column to select it and then right-click and select either:

  • Drill Down
  • Add as New Query

After you successfully get a list, you can have a list mark which looks like as follows.
1.PNG

Thanks,
Lydia Zhang

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

Re: Query for parameter suggested values (global variable for entire project?)

Thank you bro! it helped me a lot! (y)

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 80 members 1,323 guests
Please welcome our newest community members: