电源查询Error.Record

我如何吐出logging,在工作簿查询窗格中显示为错误logging?

例如,如果[AcctClass] <> [_checkAcctClass]列不匹配,则拒绝该logging为错误

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来创build错误,然后将它们放回Table.FromRecords表中可能做你想要的?

 = Table.FromRecords(Table.TransformRows(grouped, each if [AcctClass] <> [_checkAcctClass] then error "didn't match" else _), Value.Type(grouped)) 

如果第一行是一个错误,那么Table.FromRecords将完全中断,但是可以通过告诉它什么样的表types来解决这个问题。

示例mashup:

 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