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
Dutch
Regular 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

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] )
)

View solution in original post

3 REPLIES 3
Stachu
Community Champion
Community Champion

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] )
)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

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] )
)

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.

 

 

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.