Forum Discussion
Calling TVF with parameter from slicer
- 9 months ago
Hi sriramanat ,
I know this feature can be a bit confusing at first. I can’t do a Teams call, but I’m happy to guide you through the steps as clearly as possible.
This is the official Microsoft article that explains exactly how to pass a slicer value into a SQL query or TVF using Dynamic M Query Parameters: Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn.
If you’re still having trouble after reviewing it, please share more details or a screenshot of your setup. That will help in resolving the issue.
Regards,
Yugandhar.
Hi
You can try first creating an M parameter in Power Query like
EmployeeId = 1
and use that M parameter inside a query that calls your table valued function.
let
Source = Sql.Database("ServerName", "DBName",
[Query = "SELECT * FROM dbo.GetDirectReports(" & Text.From(EmployeeId) & ")"])
in
Source
then use EmployeeID in the slicer field, this way when select an employee in the dropdown, Power BI would requery the TVF, passing that EmployeeID to the SQL function (only under DirectQuery, for Import you'd need to refresh).