Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
2NV_DB
Regular Visitor

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:

2024-02-20_12h40_39.png

 

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,

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

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

vbinbinyumsft_0-1708496075353.png

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.

View solution in original post

1 REPLY 1
v-binbinyu-msft
Community Support
Community Support

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

vbinbinyumsft_0-1708496075353.png

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.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors