How to change the data of a sample .pbix? - powerbi

I want to change the data of a sample .pbix but when I'm updating the data can not find the path of the Excel since I don't have it. Is there a way without having it?

You can check exists source from Transform data --> data source settings and find the path of exists excel and in case if you did not found you can add other data sources to replace it.

Related

Apache Beam/Dataflow- passing file path to ReadFromText

I have a use case where I want to read the filename from a metadata table, I have written a pipeline function to read the metadata table, but I am not sure how can I pass this information to ReadFromText as it only takes string as input, Is it possible to assign this value to ReadFromText(). Please suggest some workarounds or ideas how to achieve this, Thanks
code: pipeline | 'Read from a File' >> ReadFromText(I want to pass the file path here?,
skip_header_lines=1)
Note: There will be various folders and files in storage, files are in csv format, but in my use case I can't directly pass the storage location or filename to file path in ReadFromText. I want to read it from metadata and pass the value. Hope I am clear, Thanks
I don't understand why you need to read the metadata. If you want to read all the files inside a folder, you can just provide a blob. This solution working in python, not sure about java.
p|readfromtext("./folder/*.csv")
"*" is the blob here, which allows pipeline to read all the patterns matching .csv. You can also add something at the starting.
What you want is textio.ReadAllFromText which reads from a PCollection instead of taking a string directly.

Is it possible to save reports and data transformation steps in PowerBI?

I have prepared some reports based on the files I prepared. I am wondering is it possible to save this report (measures and visualizations) and also the steps I made while transforming data? I want to be able to load new files (which in the structure are the same as the ones I used creating my report) and the data transformation and report done automatically on this updated data.
Is it possible?
You can save it as a template - file extension pbit. It saves only the structure of the file, without actual data. When opening the report it refreshes it, and if there are parameters in the report (e.g. folder/file path or server address) it will refresh it considering the input values
you can read more here
https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-templates
You can simply save your file as a template.

Load files from folder with a custom query with power BI

I am trying to load csv files from a folder but I need to apply several custom steps to each file, including dropping the PromoteHeaders default.
I have a custom query that can load a single file successfully. How do I turn it into a query that loads all files in a folder?
By default, File.folder's "promoteHeaders" messes up my data because of a missing column name (which my custom query fixes).
The easiest way to create a function that reads a specific template of file is to actually do it. Just create the M to read it and by right click on the entity transform it to a function.
After that is really simple to transform your M so it uses parameters.
You can create a blank query and replace the code with this on as an example, customize with more steps to deal with your file requirements.
= (myFile) => let
Source = Csv.Document(myFile,[Delimiter=",", Columns=33, Encoding=1252, QuoteStyle=QuoteStyle.None])
in
Source
And then Invoke Custom Function for each file with the content as the parameter.

add macro to excel using python xlswriter with data in original excel

I'm using the following code to add a Macro to Excel. I notice that the data / other WorkSheets from the original Excel had dropped completely but the Macro is showing.
This is the code that I am using:
import xlsxwriter
workbooks = xlsxwriter.Workbook('C:\\Users\\user\Desktop\\test.xlsm')
workbooks.add_vba_project('C:\\Users\\user\\Desktop\\vbaProject.bin')
workbooks.close()
I used the link http://xlsxwriter.readthedocs.io/example_macros.html and it seems to be the same from another page https://redoakstrategic.com/pythonexcelmacro/
I wondered if there is another library that I should use for this?
I tried the following link Use Python to Inject Macros into Spreadsheets it seems that here again the data from the original file is overwritten. Not sure if this is a duplicate or not, or if I missed something rather obvious ?
Thanks
Unfortunately, xlsxwriter can't load information from already existing Excel workbooks; it is only used for making new ones. You are overwriting your old workbook with a blank one that has your macros.
If you need to load information, look into openpyxl. It can be used for creating .xlsm files.
One way around it is to create the macro you want in another Excel so we can execute it to affect the other Excel. Then using win32.com it runs the VBA.
enter code here
#import win32com.client
#xl=win32com.client.Dispatch("Excel.Application")
#xl.Workbooks.Open(Filename="C:\\macro.xlsm",ReadOnly=1)
#xl.Application.Run("macro")
#xl = 0

read file from url path and display in chart format

i working on one project. i want to read file which path from url,this file containing xml data i have to show this data in chart format.
Basically, your steps may be these:
Validate the URL data (StructKeyExists + FileExists + isFile).
Read and parse XML file, you can do this with XmlParse.
Convert XML object into the query (see query functions).
Render the data using great charting tags.
If you want more detailed help -- please expand your question, to make it more specific.