要实现您在Power BI中提到的目标,最好的方法是利用
parameters
假设我们有一个名为
SalesJan2009.csv
. 当您将其导入Power BI时,您应该具有以下内容:
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\
),我们可以在Power BI中设置一个参数:
然后我们可以更新查询以使用参数:(query->Advanced Editor)
let
Source = Csv.Document(File.Contents(#"FileLocation" & "SalesJan2009.csv"), ...
...
P、 你可以进一步
export the Power BI file as a template
允许用户将其实例化为新的Power BI桌面报告(PBIX文件)。