cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Happy_Matty Occasional Visitor
Occasional Visitor

Database Name Changes Daily

I get a daily SQL .bak file from my ERP system. I restore the .bak file into the SQL server on a daily basis. The .bak file name contains a date and time stamp so every file name is different. 

 

How do I get Power BI to associate with the newest database automaticaly? 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Database Name Changes Daily

@Happy_Matty add something like this in advanced editor in edit query

 

let
dbName = DateTime.ToText(DateTime.FixedLocalNow(), "yyyyMMdd" ),
Source = Sql.Database("yoursqlservername", dbName),
…and next steps





Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Appreciate your Kudos Smiley Happy
Feel free to email me with any of your BI needs.





2 REPLIES 2
Super User
Super User

Re: Database Name Changes Daily

@Happy_Matty you can create a variable in M and concatenate it with date/time to get the database name and the use that in SQL connection to change database name dynamically.






Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Appreciate your Kudos Smiley Happy
Feel free to email me with any of your BI needs.





Super User
Super User

Re: Database Name Changes Daily

@Happy_Matty add something like this in advanced editor in edit query

 

let
dbName = DateTime.ToText(DateTime.FixedLocalNow(), "yyyyMMdd" ),
Source = Sql.Database("yoursqlservername", dbName),
…and next steps





Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Appreciate your Kudos Smiley Happy
Feel free to email me with any of your BI needs.





Helpful resources

Announcements
Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 315 members 3,344 guests
Please welcome our newest community members: