如何吐出记录,以错误记录的形式显示在工作簿查询 Pane 中?
例如,如果[AcctClass] <> [_checkAcctClass]列不匹配,则将该记录拒绝为错误
let
source = AccountIDsWithDuplicates,
grouped = Table.Group(source, {"AcctID"}, {{"AcctClass", each List.Max([AcctClass]), type logical}, {"_checkAcctClass", each List.Min([AcctClass]), type logical}, {"Sum_Bal", each List.Sum([#"Bal_EUR"]), type number}}),
// Make sure accounts only have one AcctClass
ErrorRecords = Table.SelectRows(grouped, each([AcctClass] <> [_checkAcctClass])
in
grouped
最佳答案
组合Table.TransformRows
来创建错误,然后将它们重新放入Table.FromRecords
的表中可能会做您想要的?
= Table.FromRecords(Table.TransformRows(grouped, each if [AcctClass] <> [_checkAcctClass] then error "didn't match" else _), Value.Type(grouped))
如果第一行有错误,则
Table.FromRecords
将完全中断,但是您可以通过告诉它期望的表类型来解决此问题。混搭示例:
let
Source = Csv.Document("AcctID,AcctClass
1,false
1,true
2,true
2,true"),
#"Promoted Headers" = Table.PromoteHeaders(Source),
AccountIDsWithDuplicates = Table.TransformColumnTypes(#"Promoted Headers",{{"AcctID", Int64.Type}, {"AcctClass", type logical}}),
grouped = Table.Group(AccountIDsWithDuplicates, {"AcctID"}, {{"AcctClass", each List.Max([AcctClass]), type logical}, {"_checkAcctClass", each List.Min([AcctClass]), type logical}}),
ErrorRecords = Table.FromRecords(Table.TransformRows(grouped, each if [AcctClass] <> [_checkAcctClass] then error "didn't match" else _), Value.Type(grouped))
in
ErrorRecords
关于excel - 上电查询Error.Record,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31155812/