Sometimes, the simplest solutions can be the hardest to find. If you've ever found yourself scouring the internet for a way to do something that seems like it should be obvious (or trying to find that link in Stack Overflow that you've already visited, but are in need of visiting again... and again... and again...), then we have a lot in common. This can be especially frustrating when you're interacting with software; particularly, with software that you know and have been familiar for quite some time.
This blog is going to start taking on some of those small issues across a variety of programs and applications. So feel free to get excited. If you've got any suggestions, feel free to leave them in the comments below.
Let's start by solving one of those problems in this space. In case you missed it, we recently released our free code analysis tool, RapidScan, which builds an inventory of all files any directory that has code files in it. The output from which are a couple of csv files with a lot of detailed information, which we wrote about in this very space. You can then upload the output back into RapidScan and we'll perform some analysis for you or you can have a go at it yourself. When I was experimenting with the output, I found myself using Power BI, and decided to create a template file that I could use for any output of the tool. Sounds simple enough, right? Build the model and save it as a template. What if I want to prompt the user whenever they use the template for the filepath to the file? Should have been an easy addition.
And it is. It just wasn't obvious. So it falls into the category of "things I'll be googling", and makes it's way to this blog. If you're looking to create a template file in Power BI where you will be prompted to choose a file to run the template on, then you can do so by creating the input filepath as a parameter for the template.
There's plenty of information out there on how to use parameters, so this will focus on building one particular parameter. Before we get too far down that road though, make sure that you're needs are satisfied by creating a template file. If you're meaning to open up a Power BI model to an ever changing dataset, then you may not need to use a template file. If you have a model that is built as a project file already connected to a specific data file (with a particular filepath), but the data in the file is being updated (either regularly or irregularly), then all you have to do is refresh the data in Power BI. Right click on your data in the Power BI client and hit refresh. Easy!
If you're looking to point a project file at a different file, you could load the new file into the same project that you already have the original file in, but using a template makes so much more sense.
If you've got already got a project file where you want to be able to upload a new dataset (with the same structure) already built, just follow the steps below to build the template. (And feel free to acknowledge the greatness of the consummate drawn blue arrows in the images below.)
As was previously noted, any new data files that you upload into the template will need to have the same structure (the same columns) as the original file had.
And that's it! Now you have a template file that will prompt the user for a new filepath if you want to point your Power BI model at a new file... and it only took 11 steps (with 10 beautifully drawn blue arrows in the screenshots above).
And don't forget to get your free copy of RapidScan!