Excel Power Query - 如果记录字段不存在则停止查询

问题描述 投票:0回答:1

我正在运行一个查询,该查询返回包含多个字段的记录。 如果记录包含字段“CashField”,则查询将照常继续。但是,如果该字段不存在,是否有办法彻底终止查询并退出函数,即不运行后续步骤?


let
    Source = Excel.CurrentWorkbook(){[Name="CASH_FLOW_QUERY"]}[Content],
    ...
    res = Record.HasFields(Source, "CashField"),
in
    res

尝试 if 语句和错误处理但没有成功

excel powerquery m
1个回答
0
投票

怎么样

let Source = Excel.CurrentWorkbook(){[Name="CASH_FLOW_QUERY"]}[Content],
x =  if List.Contains(Table.ColumnNames(Source),"Cash Field") then PutNameOfAnotherQueryorFunctionHere else null
in x
© www.soinside.com 2019 - 2024. All rights reserved.