简体   繁体   中英

Power Query Table.Group List.Sum(two columns)

Trying to figure out how to perform the sum of two columns inside a Table.Group step.

This one throws:

Expression.Error: We cannot convert Type to List type.

M Code:

= Table.Group(PreviousStep, {"PF"}, {{"ColumnName", each List.Sum({[Column1], [Column2]})}, type number})

M Gurus: Is this even possible?

Objective: Simplify steps (actually I have 12 columns I want to reduce to 6 - adding pairs, grouping them, all in one simple step)

You can kind of do it if you create a custom column to sum within that step. Something like this:

= Table.Group(
      PreviousStep,
      {"PF"},
      {{"ColumnName",
        each List.Sum(
                 Table.AddColumn(
                     _,
                     "Custom", each [Column1] + [Column2]
                 )[Custom]
             ),
        type number
      }}
 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM