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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
TRADER083
Helper I
Helper I

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
Super User
Super User

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
Super User
Super User

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.