2017-09-06 86 views
1

有沒有辦法在PowerBI中創建交互式對話框?PowerBI中的交互式對話框

我具有R腳本嵌入到查詢編輯器,我想有一個交互方面的地方,我可以使用:

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

該輸入將被用作用於讀取CSV文件位置和每次有人打開並執行PowerBI文件的主副本時,他們都可以輸入新的文件位置。

我也對html,javascript,python開放......任何可以幫助的東西。

回答

2

實現您在Power BI中提到的最佳方法是使用parameters並將您的查詢參數化以獲取csv文件。

假設我們有一個名爲SalesJan2009.csv的csv文件。當你將其導入到Power BI,你應該有這樣的:

text/csv

data

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" 

如果我們希望用戶輸入該文件的位置(即\\Mac\Home\Downloads\),我們可以設置一個參數在電力BI:

new parameter

file location

然後,我們可以更新查詢中使用的參數:(查詢 - >高級編輯)

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

如果用戶想改變參數(文件位置)以後,就可以編輯的參數和應用更改以刷新數據。

edit parameters

enter parameters

apply changes

附:您甚至可以進一步export the Power BI file as a template以允許用戶將其實例化爲新的Power BI Desktop報告(PBIX文件)。