Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Team,
In my project i have requirement to execute stored procedure using 2 dynamic parameter in Direct query method. I am able to execute the procedure using one parameter. But, when I try to execute 2 parameter i am getting error.
Below is the screenshot of power M query code from advance editor. and error also attaching.
It would be really helpful if anyone of here can help me to fix this issue.
Thanks in advance.
count your single quotes. You are missing a couple and forgot to escape others.
After checking all the quotes still i am getting the same error.
let
CompanyId = Text.From(P_COMPANY_ID), // Ensure P_COMPANY_ID is defined
PeriodRange = Text.From(periodRange), // Ensure periodRange is defined
EscapedPeriodRange = "'" & Text.Replace(PeriodRange, "'", "''") & "'", // Escape single quotes in periodRange
Query = "SELECT * FROM OPENROWSET('SQLNCLI','Server=.......\XportUAT;Trusted_Connection=yes;','EXEC Xport_UAT_NEW.dbo.USP_GET_PERIOD_DATA_FS_BY_PERIODRANGE_SH @pCompany_Id=" & CompanyId & ", @PeriodRange=" & EscapedPeriodRange & "')",
Source = Sql.Database("......\XportUAT", "Xport_UAT_NEW", [Query=Query])
in
SourceI tried new above code. Could you please let me know where i am doing mistake. it would be helpful if you can suggest me in detail.
what's the purpose of
SELECT * FROM OPENROWSET
?
Looks like your SP is not even part of the query.
SELECT * FROM OPENROWSETThat link is irrelevant and/or misleading.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |