Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi All,
I have a dashboard for which data is coming from stored procedures in SQL server. I want my dashboard to have the lastest data.
Can anyone suggest me how yo automate the data load into Power BI with system date.
The stored procedures run when we give system date as input parameter.
Please suggest
Solved! Go to Solution.
HI @Anonymous,
It seems like you missed the right 'quotation' in your query that stored the 'store procedures', please add it to confirm if the issue fixed:
Source =
Sql.Database(
"test",
"test",
[
Query =
"DECLARE @return_value int EXEC @return_value = [dbo].[usp_Response_SLA] @date = "
& Date.ToText(Date.From(DateTime.LocalNow()),"MM/dd/yyyy")
]
)
Notice:
1.'02-09-2021' will be generated by the right part M query function, you not need to add them to your query.
2. I also modify the generated date functions to get the same format as you shared.
Regards,
Xiaoxin Sheng
Hi @Anonymous,
I think you can try to parameterize your connection string to send the current system date and use it as a parameter to get data.
M query DateTime.LocalNow
Regards,
Xiaoxin Sheng
Thank you for the reply can you please elaborate the steps in details.
Hi @Anonymous,
You can invoke your store procedures with the function that I mention.
Sample steps:
1. Past the 'Stored Procedure' string into the SQL statement of your connector: (advanced option)
EXECUTE [dbo].[xxxxxxx] @date= xxxxx
Import data from a database using native database query
2. Enter to 'query editor' and navigate to the 'advanced editor' to modify the steps to concatenate the raw string with 'DateTime' functions:
Source =
Sql.Database(
"test",
"test",
[
Query =
"EXECUTE [dbo].[xxxxxxx] @Date= "
& Text.From(DateTime.LocalNow())
]
)
Power Query and Stored Procedures with Parameters
Regards,
Xiaoxin Sheng
Hi @v-shex-msft ,
Thank you for the reply, I tried using this but its thorwing below error.
The below is my Strored Procedure in Power BI
DECLARE @return_value int
EXEC @return_value = [dbo].[usp_Response_SLA]
@date = '02-09-2021'
& Text.From(DateTime.LocalNow()) -----------------I added as per your suggestion here
SELECT 'Return Value' = @return_value
HI @Anonymous,
It seems like you missed the right 'quotation' in your query that stored the 'store procedures', please add it to confirm if the issue fixed:
Source =
Sql.Database(
"test",
"test",
[
Query =
"DECLARE @return_value int EXEC @return_value = [dbo].[usp_Response_SLA] @date = "
& Date.ToText(Date.From(DateTime.LocalNow()),"MM/dd/yyyy")
]
)
Notice:
1.'02-09-2021' will be generated by the right part M query function, you not need to add them to your query.
2. I also modify the generated date functions to get the same format as you shared.
Regards,
Xiaoxin Sheng
@Anonymous , refer if this older solution can offer any help
User | Count |
---|---|
84 | |
80 | |
72 | |
71 | |
55 |
User | Count |
---|---|
108 | |
106 | |
93 | |
84 | |
66 |