代码之家  ›  专栏  ›  技术社区  ›  ASavage

PowerBI中的交互式对话框

  •  2
  • ASavage  · 技术社区  · 7 年前

    有没有办法在PowerBI中创建交互式对话框?

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

    该输入将用作读取csv的文件位置,每次有人打开并执行PowerBI文件的主副本时,他们都可以输入一个新的文件位置。

    我也对html,javascript,python开放。。。任何有帮助的事情。

    1 回复  |  直到 7 年前
        1
  •  3
  •   Foxan Ng    7 年前

    要实现您在Power BI中提到的目标,最好的方法是利用 parameters

    假设我们有一个名为 SalesJan2009.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\ ),我们可以在Power BI中设置一个参数:

    new parameter

    file location

    然后我们可以更新查询以使用参数:(query->Advanced Editor)

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

    edit parameters

    enter parameters

    apply changes

    P、 你可以进一步 export the Power BI file as a template 允许用户将其实例化为新的Power BI桌面报告(PBIX文件)。