Interactive Dialog Box in PowerBI

痞子三分冷 提交于 2019-12-11 13:23:09

问题


Is there a way to create an interactive Dialog box in PowerBI?

I have R script embedded into the query editor, and I would like to have an interactive aspect to where I can use:

    file<-winDialogString("File input?","")

This input would be used as the file location for a read csv and everytime someone opens and executes the Master copy of the PowerBI file, they can input a new file location.

I am also open to html, javascript, python... anything that could help.


回答1:


The best way to achieve what you mentioned in Power BI is to make use of parameters and parameterize your queries to get the csv file.

Say we have a csv file named SalesJan2009.csv. When you import it to Power BI you should have something like:

let
    Source = Csv.Document(File.Contents("\\Mac\Home\Downloads\SalesJan2009.csv"),[Delimiter=",", Columns=12, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Transaction_date", type datetime}, {"Product", type text}, {"Price", Int64.Type}, {"Payment_Type", type text}, {"Name", type text}, {"City", type text}, {"State", type text}, {"Country", type text}, {"Account_Created", type datetime}, {"Last_Login", type datetime}, {"Latitude", type number}, {"Longitude", type number}})
in
    #"Changed Type"

If we want users to input the file location (i.e. \\Mac\Home\Downloads\), we can set up a parameter in Power BI:

Then we can update the query to use the parameter: (Query -> Advanced Editor)

let
    Source = Csv.Document(File.Contents(#"FileLocation" & "SalesJan2009.csv"), ...
    ...

If users want to change the parameter (file location) later on, they can edit the parameter and apply changes to refresh the data.

P.S. You can even further export the Power BI file as a template to allow users to instantiate it as a new Power BI Desktop report (PBIX file).



来源:https://stackoverflow.com/questions/46080640/interactive-dialog-box-in-powerbi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!