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

Calculate sum from another table based on 2 of 3 linked items

I have 2 data tables that are linked through 3 master data tables.

 

Table one:

Period - Company Code - Profit Center - Sales Amount

 

Table two:

Period - Company Code - Profit Center - Net assets amount

 

I like to add the summary sales from table one to table 2, but it should only match for period and company code and ignore the link for Profit center.

 

I tried with calculate(sum(table1[sales amount]),allexcept(table2[Period],table2[Company code]))

 

but this doesn't work.

 

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Dutch Frequent Visitor
Frequent Visitor

Re: Calculate sum from another table based on 2 of 3 linked items

Figured it out:

Thank you

 

=
CALCULATE (
    SUM ( Table1[Sales Amount] ),
    FILTER (
        ALL ( Table1),
        Table1[Company Code] = Table2[Company Code]
    ),
    FILTER ( ALL ( Table1), Table1[Period] = Table2[Period] )
)
3 REPLIES 3
Super User
Super User

Re: Calculate sum from another table based on 2 of 3 linked items

try this as a calculated column in Table2

=
CALCULATE (
    SUM ( Table1[Sales Amount] ),
    FILTER (
        ALL ( Table1[Company Code] ),
        Table1[Company Code] = Table2[Company Code]
    ),
    FILTER ( ALL ( Table1[Period] ), Table1[Period] = Table2[Period] )
)
Dutch Frequent Visitor
Frequent Visitor

Re: Calculate sum from another table based on 2 of 3 linked items

Thank you, but it didn't work.

It didn't ignore the link on the profit center. If I would have 5 rows with different profit centers for a specific period and a specific company code, I want all 5 lines to get the same answer. In table 1 there is more than one row for a specific period and a specific company code. Those need to be added together and put on all 5 lines in table 2.

 

 

Dutch Frequent Visitor
Frequent Visitor

Re: Calculate sum from another table based on 2 of 3 linked items

Figured it out:

Thank you

 

=
CALCULATE (
    SUM ( Table1[Sales Amount] ),
    FILTER (
        ALL ( Table1),
        Table1[Company Code] = Table2[Company Code]
    ),
    FILTER ( ALL ( Table1), Table1[Period] = Table2[Period] )
)