【问题标题】:PowerQuery Filter on Parameter Value参数值的 Power Query 过滤器
【发布时间】:2017-08-15 22:16:54
【问题描述】:

我有一个名为 FinancialQuery 的 Excel PowerQuery FinancialQuery 依赖于名为 Parameters 的表中的值 每次用户更改参数值并点击刷新时,查询都会根据用户输入的数据带过来

但是,财务查询的最后一步是根据相同的参数值过滤行 而不是“17213”

#"Filtered Rows On OU" = Table.SelectRows(#"Renamed Columns", each [OperatingUnit] = "17213")

我希望过滤器基于相同的函数值 fullfilepath

#"Filtered Rows On OU" = Table.SelectRows(#"Renamed Columns", each [OperatingUnit] = fullfilepath)

当我输入该语法时,powerquery 认为我正在过滤单词 fullfilepath

有人可以帮我语法吗?

这是我的完整代码

'Parameters Table
Parameter   Value
File Path   17213.csv



' fnGetParameter
(ParameterName as text) =>
 let
     ParamSource = Excel.CurrentWorkbook(){[Name="Parameters"]}[Content],
     ParamRow = Table.SelectRows(ParamSource, each ([Parameter]=ParameterName)),
     Value=
    if Table.IsEmpty(ParamRow)=true
    then null
    else Record.Field(ParamRow{0},"Value")
in
    Value


'Financial Query
let
    fullfilepath = fnGetParameter("File Path"),
    Source = SharePoint.Files("https://Personal.sharepoint.com/FOA/BD", [ApiVersion = 15]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Folder Path] = "https://Personal.sharepoint.com/FOA/BD/Budget/DataSources/Financials/") and ([Extension] = ".csv") and ([Name] = fullfilepath)),
    #"ActiveFile" = #"Filtered Rows"{[Name=fullfilepath,#"Folder Path"="https://Personal.sharepoint.com/FOA/BD/Budget/DataSources/Financials/"]}[Content],
    #"Imported CSV" = Csv.Document(#"ActiveFile",[Delimiter=",", Columns=23, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"P01", Currency.Type}, {"P02", Currency.Type}, {"P03", Currency.Type}, {"P04", Currency.Type}, {"P05", Currency.Type}, {"P06", Currency.Type}, {"P07", Currency.Type}, {"P08", Currency.Type}, {"P09", Currency.Type}, {"P10", Currency.Type},{"P11", Currency.Type},{"P12", Currency.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"P01", "01"}, {"P02", "02"}, {"P03", "03"}, {"P04", "04"}, {"P05", "05"}, {"P06", "06"}, {"P07", "07"}, {"P08", "08"}, {"P09", "09"}, {"P10", "10"}, {"P11", "11"}, {"P12", "12"}}),
    #"Filtered Rows On OU" = Table.SelectRows(#"Renamed Columns", each [OperatingUnit] = "17213")    
in
    #"Filtered Rows On OU"

我还附上了一张我的 powerquery 语法的图片。

【问题讨论】:

  • 我相信this 描述了你的情况。

标签: excel powerbi powerquery m


【解决方案1】:

我添加了 Text.Replace(fullfilepath,".csv","") 最终语法

let
    fullfilepath = fnGetParameter("File Path"),
    Source = SharePoint.Files("https://ihcorp.sharepoint.com/FOA/BD", [ApiVersion = 15]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Folder Path] = "https://ihcorp.sharepoint.com/FOA/BD/Budget/DataSources/Financials/") and ([Extension] = ".csv") and ([Name] = fullfilepath)),
    #"ActiveFile" = #"Filtered Rows"{[Name=fullfilepath,#"Folder Path"="https://ihcorp.sharepoint.com/FOA/BD/Budget/DataSources/Financials/"]}[Content],
    #"Imported CSV" = Csv.Document(#"ActiveFile",[Delimiter=",", Columns=23, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"P01", Currency.Type}, {"P02", Currency.Type}, {"P03", Currency.Type}, {"P04", Currency.Type}, {"P05", Currency.Type}, {"P06", Currency.Type}, {"P07", Currency.Type}, {"P08", Currency.Type}, {"P09", Currency.Type}, {"P10", Currency.Type},{"P11", Currency.Type},{"P12", Currency.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"P01", "01"}, {"P02", "02"}, {"P03", "03"}, {"P04", "04"}, {"P05", "05"}, {"P06", "06"}, {"P07", "07"}, {"P08", "08"}, {"P09", "09"}, {"P10", "10"}, {"P11", "11"}, {"P12", "12"}}),
    #"Filtered Rows1" = Table.SelectRows(#"Renamed Columns", each [OperatingUnit] = Text.Replace(fullfilepath,".csv",""))
in
    #"Filtered Rows1"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 2022-07-01
    • 1970-01-01
    • 2016-12-23
    相关资源
    最近更新 更多