Forum Discussion
Sum column only if value in another column does not equal x
Hello all,
I have the following scenario and I'm stumped on how to tackle it.
I have two tables like so:
I would like to sum the Sales column in Table2, only if the Percentage in Table 1 is not equal to 123 for the same Customer Number and Category.
Is this possible? I've considered merging my queries but I'm not sure how to develop a measure to sum accross columns.
Cheers,
- Anonymous2 years ago
Hi 2NV_DB ,
Please try below steps:
1. merge Table1 and Table2 in Power Query
let Source = Table.NestedJoin(Table2, {"Customer Number"}, Table1, {"Customer Number"}, "Table1", JoinKind.Inner), #"Expanded Table1" = Table.ExpandTableColumn(Source, "Table1", {"Customer Number", "Category", "Percentage"}, {"Table1.Customer Number", "Table1.Category", "Table1.Percentage"}) in #"Expanded Table1"2. create a measure with below dax formula
Conditional Sales Sum = CALCULATE( SUM(Table3[Sales]), FILTER( Table3, Table3[Table1.Percentage] <> 123 ) )3. add a card visual with measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi 2NV_DB ,
Please try below steps:
1. merge Table1 and Table2 in Power Query
let Source = Table.NestedJoin(Table2, {"Customer Number"}, Table1, {"Customer Number"}, "Table1", JoinKind.Inner), #"Expanded Table1" = Table.ExpandTableColumn(Source, "Table1", {"Customer Number", "Category", "Percentage"}, {"Table1.Customer Number", "Table1.Category", "Table1.Percentage"}) in #"Expanded Table1"2. create a measure with below dax formula
Conditional Sales Sum = CALCULATE( SUM(Table3[Sales]), FILTER( Table3, Table3[Table1.Percentage] <> 123 ) )3. add a card visual with measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.