Forum Discussion
Power Bi Report Builder - DAX Query from Performance analyzer multiple parameter values issue
- 4 years ago
So the basic order of operations for building a query as an expression is as follows:
1) you create a new data set and link it to a connection.
2) then you click the fx button to open the expression editor
3) then you start the expression with an equals and an opening double quote character eg. ="
4) then I normally open a text editor paste my query in there and do a global search for any double quote characters " and replace them with 2 double quote characters ""5) then you paste in your query and at the end you add a closing double quote character "
="DEFINE VAR __DS0FilterTable = TREATAS({2021}, 'DateTable'[Received]) VAR __DS0FilterTable2 = TREATAS({""November""}, 'CCST'[MonthName]) VAR __DS0FilterTable3 = TREATAS({""LEGACY""}, 'CCST'[Model]) VAR __DS0FilterTable4 = TREATAS({""DIY""}, 'CCST'[Type]) VAR __DS0FilterTable5 = TREATAS({""Normal""}, 'CCST'[Status]) VAR __DS0FilterTable6 = TREATAS({""OTHERS""}, 'CCST'[Category]) EVALUATE TOPN( 501, SUMMARIZECOLUMNS( ROLLUPADDISSUBTOTAL( 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[Year], ""IsGrandTotalRowTotal"", ROLLUPGROUP( 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[Month], 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[MonthNo] ), ""IsDM0Total"" ), __DS0FilterTable, __DS0FilterTable2, __DS0FilterTable3, __DS0FilterTable4, __DS0FilterTable5, __DS0FilterTable6, ""SumReceived"", CALCULATE(SUM('CCST'[Qty])), ""Good"", 'CCST'[Good], ""Good__"", 'CCST'[Good %] ), [IsGrandTotalRowTotal], 1, 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[Year], 1, [IsDM0Total], 1, 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[MonthNo], 1, 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[Month], 1 ) ORDER BY [IsGrandTotalRowTotal], 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[Year], [IsDM0Total], 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[MonthNo], 'LocalDateTable_9a516b7e-ac4d-49d6-a22c-5318bf076cd8'[Month] "So the above is just a hard coded expression, to incorporate parameters in you would take the exising hard coded filters and replace them. So the following month filter
TREATAS({""November""}, 'CCST'[MonthName])would become something like the following to manually join in the value from a parameter called Month
TREATAS({""" + Parameters!Month.Value + """}, 'CCST'[MonthName]) - 4 years ago
Anonymous wrote:
I'm not experiencing an error. so far i encountered no data displayed on my report. Imap the query field to field by copying the one from the query code.
This will be the cause of your problem. Because of the way Report Builder executes dax queries certain characters in the fields names get replaced with underscores. So if you have not mapped using the correctly encoded names you will just get an empty string in your fields. So if you have asked for the field "[Sales Amount]" but the query engine in Report Builder returns it as "__Sales_Amount__" then your dataset will contain rows, but all the fields will be blank.
It is much easier to use the approach I suggested in my previous reply and paste in the raw query first and let Report Builder generate the field mappings before you turn your query into an expression.
Anonymous wrote:
I'm not experiencing an error. so far i encountered no data displayed on my report. Imap the query field to field by copying the one from the query code.
This will be the cause of your problem. Because of the way Report Builder executes dax queries certain characters in the fields names get replaced with underscores. So if you have not mapped using the correctly encoded names you will just get an empty string in your fields. So if you have asked for the field "[Sales Amount]" but the query engine in Report Builder returns it as "__Sales_Amount__" then your dataset will contain rows, but all the fields will be blank.
It is much easier to use the approach I suggested in my previous reply and paste in the raw query first and let Report Builder generate the field mappings before you turn your query into an expression.
The report is already working if i choose one year data. but i'm having issues if i pulled data three years data. I have 33 columns on my report. May I know what are the fixes should I do in regards with this error. Thanks. by the way, below is the error.
Resource Governing: This query uses more memory than the configured limit.
The query — or calculations referenced by it — might be too memory-intensive to run.
To run this query, you could simplify the query or its calculations, or reach out to your capacity administrator to see if they can increase the per-query memory limit.
- d_gosbell4 years agoSuper User
So the two possible fixes for this are spelled out in the error message itself.
Anonymous wrote:
To run this query, you could simplify the query or its calculations, or reach out to your capacity administrator to see if they can increase the per-query memory limit.
As long as you are not trying to export millions of records the issue is most likely one of your measures requiring a lot of memory to calculate.
I would suggest copying your query out to something like DAX Studio or SSMS where you can easily modify it an run it repeatedly. Then comment out all your measures and include a simple measure like one that is just a SUM of a single column or a COUNTROWS. If the query works with a simple measure then gradually add your other measures back in one at a time until you find which one(s) cause the issue. The you will need to see if you can re-write / optimize those.
- Anonymous4 years agoNot applicable
Thank you for your reply. by the way, I notice one of my parameter. I'm selecting all the values meaning i have 30 values and it show all the 30 items in my report parameter if i choose (select All), How can i display only the "All" on my Report. curretnly i did like this in my parameter expression =Join(Parameters!Year.Value,",").
'
- d_gosbell4 years agoSuper User
Anonymous wrote:
Thank you for your reply. by the way, I notice one of my parameter. I'm selecting all the values meaning i have 30 values and it show all the 30 items in my report parameter if i choose (select All), How can i display only the "All" on my Report. curretnly i did like this in my parameter expression =Join(Parameters!Year.Value,",").
'
You could check in your expression if the number of values selected in the parameter matches the number of rows in the dataset you use to populate the parameter. So the expression would look something like the following, you would just need to change the field name and dataset names in red to match those in your report.
=iif( Parameters!Year.Value.Length = Count(Fields!Year.Value, "YearDataSet"), "ALL", Join(Parameters!Year.Value, ","))