Forum Discussion
Create sumif in PowerQuery (not DAX, and not use group by feature)
- 6 years ago
Hi Anonymous ,
Try this code for a custom column:
let _item = [Column1] in
List.Sum(
Table.SelectRows(#"Changed Type", each [Column1] = _item)[Column2])Change the bold part for the last step name.
Your example worked well, even with a self-reference for the criterion. How would you do this for two or more criteria?
Hi Dave_Clark ,
You can use more conditions with variables, like:
let
_item = [Column1],
_item2 = [ColumnXXX]
in
List.Sum(
Table.SelectRows(#"Changed Type", each [Column1] = _item and [ColumnXXX] = _item2 )[Column2])
- MAFRE3 years agoFrequent Visitor
It works great, any chance you could explain how this works or any reference to a post explaining it? I understand what happens but not how you got M to do this, first time I've seen the use of a second LET to filter/sum
Edit: Found this which explains it and much more:
https://bengribaudo.com/blog/2017/11/17/4107/power-query-m-primer-part1-introduction-simple-expressions-let