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
vanessafvg
Super User
Super User

passing a calculated date parameter to multiple imports

what is the best way to calculate a date 2 years back, from the beginning of the current month and then pass that to a filter in all the tables you importing into a model.

 

Ive tried this but it doesn't seem to be coming together..

 

Ive created a calculated table in power query by placing in this in a blank query.  It comes up with the correct date.

 

= Date.AddYears(Date.StartOfMonth(DateTime.Date(DateTime.LocalNow())),-2)

 

this returns athe correct value, but  can't figure out how to pass it to a parameter, at its not showing as an available query  when i create a new parameter, what is the best way to do this?

 

thanks

 

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




1 ACCEPTED SOLUTION

Hi @vanessafvg

 

What you could potentially do is the following.

 

In the Query Editor where you have created your Date going back 2 years, Convert this to a List.

 

Then create a new Parameter, when it asks for the Suggested Values, change this in the Drop Down to Query.

This will then give you an option for which Query to use.

You can now select the List that you converted above.

 

Now that you have it set as a Parameter, you can simply use this Parameter in your filters.

 

There is another way to do this, if it does not work, which is to manually create it in the Advanced Editor, but is a bit more complex. So if you can try the above suggestion first?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

9 REPLIES 9
vanessafvg
Super User
Super User

i would really aprpeciate a response on this if anyone knows 🙂 as i am totally stuck on how to make this dynamic





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hi @vanessafvg

 

What you could potentially do is the following.

 

In the Query Editor where you have created your Date going back 2 years, Convert this to a List.

 

Then create a new Parameter, when it asks for the Suggested Values, change this in the Drop Down to Query.

This will then give you an option for which Query to use.

You can now select the List that you converted above.

 

Now that you have it set as a Parameter, you can simply use this Parameter in your filters.

 

There is another way to do this, if it does not work, which is to manually create it in the Advanced Editor, but is a bit more complex. So if you can try the above suggestion first?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

I am having an issue passing date parameters to a pentaho web service, but when passing parameter as date it says:

We cannot apply operator & to types Text and Date.

 

Below is the call that is being made to the web service on my local machine.

Parameter name is date_start

 

Web.Contents("http://localhost:8081/kettle/executeTrans/?trans=E:\pentaho\dashboard.ktr&date_start="&date_start)

 

I can not use data type of the parameter as text as i have used slicer on the dashboard and that parameter is passed as the starting date to it, and it only accepts the date data type param.

 

what should i do with it?

Hi shzincu,

 

Please post your quetion as a new topic.. this issue has already been solved so people are less likely to respond.

 

Not sure what you should do but I would try to cast the date to text before you append it? e.g.

 

Web.Contents("http://localhost:8081/kettle/executeTrans/?trans=E:\pentaho\dashboard.ktr&date_start="&Text.From(date_start))

 

sorry the syntax is probably wrong but I hop you get the idea.

"The commonality between science and art is in trying to see profoundly - to develop strategies of seeing and showing." - Edward Tufte

aha i think it might work with the list!  i only just noticed that you convert to list or table.  , i just hope it stays dynamic, thanks 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hi there.

As long as you refresh the entire data model it should be dynamic




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

it doesn't seem to be working, i have pointed it to the list to pass to the parameter, but the parameter doesn't seem to be populating?

 

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hmm.. this can be tricky depending on the data source:

 

if its in SQL DB its easy.. is it a SQL source?

 

Cheers

Greg

 

"The commonality between science and art is in trying to see profoundly - to develop strategies of seeing and showing." - Edward Tufte

unfortunately the source is in csv format





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




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.