Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

To automate data load with system date

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

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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")
            ]
        )

 

snapshotsnapshot

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

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

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

Anonymous
Not applicable

Thank you for the reply can you please elaborate the steps in details.

Anonymous
Not applicable

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

Anonymous
Not applicable

Hi @Anonymous ,

 

Thank you for the reply, I tried using this but its thorwing below error.

neelofarshama_0-1613385903291.png

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

 

Anonymous
Not applicable

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")
            ]
        )

 

snapshotsnapshot

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

amitchandak
Super User
Super User

@Anonymous , refer if this older solution can offer any help

https://community.powerbi.com/t5/Desktop/Power-bi-Incremental-Refresh-and-Stored-Procedures/td-p/1538140

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.