Forum Discussion
Dynamic M query with arbitrary values
- 1 year ago
Hi rnola16,
Thank you for reaching out to the Microsoft Fabric Community Forum.
You're on the right path using dynamic M query parameters in DirectQuery mode. Since you're passing values like birth_dt and ssn, here are a few ideas that might help troubleshoot:- Make sure both parameters are correctly linked to slicers using dummy dimension tables. This is essential for dynamic input from the report UI.
- Double-check that the names of the parameters you're using throughout the query are consistent mismatched names can cause unexpected behaviour.
- Confirm that Power BI can fold the filters back to the source system. If the filtering isn't being pushed down to the database, the dynamic behaviour may not work as expected.
- It's generally recommended to avoid directly embedding parameter values into custom SQL strings for both security and performance reasons. Power BI handles parameters more effectively when they’re passed and processed using native filtering.
If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Modified that to include s_s_n.
Updated:
let
Source = Teradata.Database("MYPROD", [Query = " SELECT
A.NAME AS FNAME,
A.BIRTH_DT AS BDATE,
A.SSN AS SSN
FROM
EMPLOYEE A
WHERE
A.BIRTH_DT ='"&birthdate&"' AND A.SSN = '"&s_s_n&"' " ] ),
FilterList = if Type.Is(Value.Type(s_s_n),List.Type) then s_s_n else {s_s_n},
FilteredRows = Table.SelectRows( Source,each List.Contains( FilterList,[SSN]))
in
FilteredRows
Get warning, "This step results in a query that is not supported in DirectQuery mode" on
FilteredRows = Table.SelectRows( Source,each List.Contains( FilterList,[SSN]))
Is it that the function is not recognized by the Teradata ?
- Deku1 year agoSuper User
Question. You are already injecting a filter into native query, although assuming only a single SSN is supplied.The other steps are just filtering again, but allow for a lookup from a list.
Which one should be used?
- rnola161 year agoAdvocate II
I'm looking to generate results with ssn as parameter ( can be single entry or multi-value ). The ssn parameter is left blank so users can enter arbitrary values and find their own records.
Eg; Select * from Employee where ssn in '"¶mter&"'
- Deku1 year agoSuper User
You need to pick between the injection of a where clause or use the table.selectcolumns. table.selectcolumns is how Chris is allowing for both single and multiple selections
- rnola161 year agoAdvocate II
When I do this, I get a warning " This step results in a query that is not supported in DirectQuery mode."
Is this feature not meant for custom SQL query in directquery mode ?
Really having a hard time to deal with PBI for a simple task.
Thanks.