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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Template using excel files

Hello,

 

I am new to power bi and just now learning about templates.  I have imported a few csv files into my project.  I now want to be able to export a template so that anyone in my comany can import their data and get the same visuals that I have set up.  My issue is that I have set up a parameter, but when I try to enter in a new data file in the template it loads the data that the template was created from.  

 

How do you set up a template that lets you import in the data that you want?

1 ACCEPTED SOLUTION

Hi @Anonymous 

Or follow the document below

https://www.seerinteractive.com/blog/how-to-create-a-power-bi-template/

 

As tested, it works.

Please uncheck the "required" option and use parameter in your connection query.

Then close&&apply, go to report view, creat visuals.

when save, select "save as "->***.pbit

Capture5.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
lbendlin
Super User
Super User

this mainly depends on where you store your CSV files and how you told Power BI to access them.

 

If you stored them in your personal documents folder then other users will have to modify the data source settings to point to their personal folder.  If you stored them in a commonly accessible OneDrive then the template will work as is with the same data.

 

In any case you may just need to educate your user how to modify the data source settings.

Anonymous
Not applicable

@lbendlin Our files are currently stored in a shared folder.  The parameter is set to ask the user for the file location.  Once the new file location is added to access the new files the template loads in the original files instead of the new ones. 

Hi @Anonymous,

 

How are you using this parameter ? Can you show the m code for this query ?



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

Proud to be a Super User!



Anonymous
Not applicable

@camargos88 

The parameter is set up as a text and the Current value is the csv file.  When opening the template it then promps you to enter a new file location. 

The source of my file is an excel workbook with the file contents of the file location.

@Anonymous ,

 

It looks like correct, can you share your m code ?

Also the data structure is the same for all the inputed files ?



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

Proud to be a Super User!



Anonymous
Not applicable

@camargos88 

The data structure is the same for all of the files.

 Power Bi.PNG

Hi @Anonymous 

Or follow the document below

https://www.seerinteractive.com/blog/how-to-create-a-power-bi-template/

 

As tested, it works.

Please uncheck the "required" option and use parameter in your connection query.

Then close&&apply, go to report view, creat visuals.

when save, select "save as "->***.pbit

Capture5.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous 

You can create a query like

(filename as text)=>
let
    Source = Csv.Document(File.Contents("*******your file location\"&filename&".csv"),[Delimiter=",", Columns=2, Encoding=65001, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"date", type date}, {"value", Int64.Type}})
in
    #"Changed Type"

 

Best Regards

Maggie

Are you export the template as template ?

As soon it opens you input the filepath and it keep the model file, not the given path ?



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

Proud to be a Super User!



You'll want to validate your M code then.  Remember code does what you tell it to do, not always what you want it to do 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors