cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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 🙂
Feel free to email me with any of your BI needs.





View solution in original post

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 🙂
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 🙂
Feel free to email me with any of your BI needs.





View solution in original post

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)