Forum Discussion
jns1087
1 year agoRegular Visitor
Q: Sumif using multiple columns and specific text
Hi. im new to power query and playing it in excel, i have crossed this idea on how to achieve this in power query. lets say i have 10 columns and i want to sum the amount in column A based on specifi...
- 1 year ago
jns1087
Use the below M code for your resultList.Sum( Table.SelectRows( Source, each (_[Column B] = "APPLE" or _[Column B] ="KIWI") and _[Column C] = "DOG" and _[Column D] = "CAGE" and _[Column E] = "ORDINARY" and _[ColumnF] = "123-456" )[Amount] )Below screenshot
Hope it helps
Regards,
sanalytics - 1 year ago
Hi jns1087 ,
Thank you for reaching out to the Fabric Community.
And thanks for sharing the M code, sanalytics . I tested it on a sample dataset and it worked well the rows filtered for Apple + Kiwi with Dog, Cage, Ordinary, and 123-456 summed up to 345 as expected.I’ve attached a PBIX file for your reference if you’d like to review it further. Please let me know if you notice any changes that are needed.
I appreciate your support on this, sanalytics .
Regards,
Yugandhar.
sanalytics
Super User
1 year agojns1087
Use the below M code for your result
List.Sum(
Table.SelectRows(
Source, each
(_[Column B] = "APPLE" or _[Column B] ="KIWI") and
_[Column C] = "DOG" and _[Column D] = "CAGE" and
_[Column E] = "ORDINARY" and _[ColumnF] = "123-456"
)[Amount] )
Below screenshot
Hope it helps
Regards,
sanalytics