The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello,
I'm working on a report that gets the data from a Table-Valued Function hosted on an Azure SQL server. That function has four parameters being "TeamList", "OwnerNameList", "AnalysisBeginDate" and "AnalysisEndDate".
I'd like to use dynamic M query parameters so when users change a value in the controls displayed on the report it'll call the function with the updated parameter values. Well, just what the functionnality seems to be offering.
I succeeded in doing so for the first two Text parameters ("TeamList" and "OwnerNameList") but I'm unable to do the same for the last two. Apparently it's because they have a Date format. I'll try to share as much details as possible not only for the sake of presenting my issue but also for people trying to use dynamic M parameters because, to me, that was a struggle.
I'll focus on the "Team" dropdown list, one of the two that actually works.
You can see, on top of the table, I added four controls that allow the user to change the parameters sent to the SQL function. For now it only works for "Team" and "Control Form Owner".
The "Team" dropdown is populated using a function call in DirectQuery mode (I've made that DirectQuery because I thought it was mandatory for dynamic M parameters though I think it only applies for the main data function call) :
let
Source = Sql.Database("<server>", "<database>", [Query="SELECT TOP 100 PERCENT *#(lf)FROM dbo.GetTeamList()#(lf)ORDER BY 1"])
in
Source
The "Team" dropdown list is a Slicer linked to the "Team" column of the "TeamListQuery" table.
And finally here is how the value of the "TeamParameter" is sent to the main data function (also DirectQuery).
let
selectedTeams = if TeamParameter = null then
"default"
else
if Type.Is(Value.Type(TeamParameter), List.Type) then
Text.Combine({"'", Text.Combine(TeamParameter, "|"), "'"})
else
Text.Combine({"'", TeamParameter, "'"}),
selectedUsers = if UserNameParameter = null then
"default"
else
if Type.Is(Value.Type(UserNameParameter), List.Type) then
Text.Combine({"'", Text.Combine(UserNameParameter, "|"), "'"})
else
Text.Combine({"'", UserNameParameter, "'"}),
selectedAnalysisStartDate = if AnalysisBeginDateParameter = null then
"default"
else
Text.Combine({"'", DateTime.ToText(AnalysisBeginDateParameter, "yyyy-MM-dd"), "'"}),
selectedAnalysisEndDate = if AnalysisEndDateParameter = null then
"default"
else
Text.Combine({"'", DateTime.ToText(AnalysisEndDateParameter, "yyyy-MM-dd"), "'"}),
finalQuery = Text.Combine({"SELECT * FROM ",
"dbo.GetControlFormStatus(",
selectedTeams, ",",
selectedUsers, ",",
selectedAnalysisStartDate, ",",
selectedAnalysisEndDate, ")"}),
Source = Sql.Database("<server>", "<database>", [Query=finalQuery])
in
Source
If I follow the exact same steps for the "AnalysisBeginDate" and "AnalysisEndDate", by that I mean : gather the list of dates through a DirectQuery mode function call (that returns an SQL DATE column) and create a Date parameter. The "Bind to parameter" dropdown list is not displayed on the corresponding column.
let
Source = Sql.Database("<server>", "<database>", [Query="SELECT *#(lf)FROM dbo.GetAnalysisBeginDateList()"])
in
Source
And it seems to be only because the column is of "Date" type, because, if I switch the type to "Text", the "Bind to parameter" dropdown list appears in the "Advanced" section :
I've followed this article on dynamic M query parameter :
https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters
There is something about "Date/Time" data type in the "Limitations" section but I think it applies to the data function call, when I'm stuck upstream.
I'd also like to state that I've followed the example in this article that's using a Date table and this does not work for me. "Bind to parameter" doesn't appear as well.
I've throughly search the Web and asked a couple of AIs for help. No success.
If someone can help me make it work that'll be awesome. Otherwise I'll have to reduce my expectations.
Cheers,
L
Hi @Loy
We haven't heard from you since last response and just wanted to check whether the solution provided has worked for you. If yes, please Accept as Solution to help others benefit in the community.
Thank you.
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
Hi,
I understand the urge of having an accepted solution but, as said previously, nothing close to a solution has been provided. Therefore, I won't be accepting anything.
I can't see any option to upload a file please let me know how to proceed.
L
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Hi @Loy
Thank you for your message. To remove data and database information from the PBIX file, please open the file in Power BI Desktop, go to Transform Data, and either delete the queries or remove all applied steps.
Additionally, you can clear stored credentials under Data source settings by selecting the connection and choosing Clear Permissions.
Once done, save the file to ensure the data and connection details are no longer retained.
Let us know if you need further guidance.
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
Hi @Loy
Sorry for the late response.
Could you please provide the pbix file share if there no sensitive information.
So that I will try my best to resolve your issue.
Best Regards,
Cheri Srikanth
Hi @v-csrikanth,
I had a look but I have troubles removing data and database information for the file.
Do you have any tips on how to achieve this please ?
Cheers,
L
Hi @Loy
Thank you for being part of the Microsoft Fabric Community.
As highlighted by @lbendlin, the proposed approach appears to effectively address your requirements. Could you please confirm if your issue has been resolved?
If you are still facing any challenges, kindly provide further details, and we will be happy to assist you.
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
Hello,
I'm sorry but I still haven't been able to make it work. For me it's not possible or the explanations provided were too vague. So I can't accept any answers as solution.
L
I created a blank report and followed the steps described in the text of this article for a Date/Time parameter and it doesn't work :
Dynamic M query parameters in Power BI Desktop
In the video only a Text parameter is used.
Does anyone has done it with a Date/Time parameter?
L
Yes. Even the Capacity Metrics App report uses a DateTime M parameter. Check the limitations in the documentation.
Can you please be more specific?
@lbendlin wrote:Yes. Even the Capacity Metrics App report uses a DateTime M parameter.
If you say so. I had a look but I'm unable to say whether a DateTime M parameter is used or not.
@lbendlin wrote:Check the limitations in the documentation.
Limitations of the dynamic M parameters? Like said in the original post, I had a look but nothing told me what I'm trying to do is impossible or is done wrong.
Cheers,
L
TimePoints/TimePoint is a mandatory filter for the Capacity Metrics app, it is a DateTime field and is bound to the M parameter for the KQL query.
I changed storage mode to Import for that query to try. The report still works but the dropdown list is now single select mode and if I try to toggle it off, it switches back on on its own. Weird, but that's not what I'm concerned about.
Any suggestions about the main issue regarding a Date table ?
Cheers,
L
The "Team" dropdown is populated using a function call in DirectQuery mode (I've made that DirectQuery because I thought it was mandatory for dynamic M parameters though I think it only applies for the main data function call) :
Quite the opposite. Using Direct Query to feed a slicer that then impacts a Dynamic M Query parameter is akin to a snake eating its tail. Or yourself sawing off the branch you are sitting on.
The values presented to the Dynamic M Parameter ideally should come from a static list (ie import mode).