Forum Discussion
Default M-query parameter used to get data
Hi jbwtp
Thanks for your answer.
I'm still trying to figure out how the parameters work before I include them in my actual report.
Here's what I'm trying to do.
I get my data from a SQL server, and I use "Direct query" to import the data. I want the user to be able to specify the period so that's where I want to use the query parameters for. To archieve this I did the following.
I created a startdate and enddate parameter in the power query-editor. I assigned a current value to those parameters as you can see in the screenshot.
I created a datetable to be used in a slicer. The datefield of that table I binded to the parameter I created earlier.
Then in my report I created a table with the summerize function to get the number of records in the table. To my suprise the number of records (59 )in the summerized table are the number of records based on the values I included when I defined the parameters.
The number of records in the actual table are based on the slicer parameters (31). Whenever I change the parameters I get a popup with the SQL query which shows the parameters I defined in the slicers.
My expectation is that the number of records of both should be the same for both, because one is a summarized table of the other, but maybe I'm missing something or doing something wrong.
Thanks in advance.
Hi DCraneBMF,
Thnaks for providing the details. I guess you are following something like: https://blog.crossjoin.co.uk/2022/02/20/tsql-table-valued-functions-and-dynamic-m-parameters-in-power-bi-directquery/
Everything you do makes sense, I can't test it myself as I don't SQL (of for this reason any folding source). And from what I can see the dynamic query does return a correctnumberof lines,except for the Summarize function. Do you want to try any other function? I remember reading that SUMMARIZE behaves quite different to expectations in some scenarios. I suspect it may remove your filter and trigger re-run the query. Whatabout something like simple CALCULATE?
Kind regards,
John