cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TRADER083
Frequent Visitor

Summing Table 1 based on criteria in Table 2

Hi everyone,

 

I have a very simple question but couldn't make it work. I have Table 1 and 2 which are 1-to-1 relationship. I want to create a SUM column in Table 2 which sums the value from Table 1 but filter by Table 2's criteria column. There are multiple criteria, showing one for simplicity.

 

Table 1

KeyValue
1100
2200
3400

 

Table 2

KeyCriteriaSum
1A300
2A300
3B400

 

Thank you,

Kevin

1 ACCEPTED SOLUTION
FreemanZ
Community Champion
Community Champion

try to create a column with the code below:

SUM =
VAR CurrentCriteria = Table2[Criteria]
RETURN
CALCULATE(
    SUM(Table1[Value]),
    ALL(),
    Table2[Criteria] = CurrentCriteria
)
 
I tried and it worked like this:

 

FreemanZ_0-1669785855551.png

 

View solution in original post

2 REPLIES 2
FreemanZ
Community Champion
Community Champion

try to create a column with the code below:

SUM =
VAR CurrentCriteria = Table2[Criteria]
RETURN
CALCULATE(
    SUM(Table1[Value]),
    ALL(),
    Table2[Criteria] = CurrentCriteria
)
 
I tried and it worked like this:

 

FreemanZ_0-1669785855551.png

 

or with this code:

SUM2 =
CALCULATE(
    SUM(Table1[Value]),
    ALLEXCEPT(Table2,Table2[Criteria])
)

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.