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
sfink22
Helper I
Helper I

DAX to sum column based on another table

Hello! Trying to work out the right equation to sum a column based on another table for a budget dashboard. Here is my setup:

 

Table 1 has the budget info by period, like this:

Period    Budget

1            $500

2            $350

etc.

 

Table 2 has the actual charges accumulated YTD:

Period    ChargeName    Amount

1            Cell phone        $110

1            Lunch                $15

etc.

 

How do I add a column to Table 1 that sums all of the charges for Period 1 from Table 2? So I end up with this:

 

Period    Budget    Spent

1            $500        $125

2            $350

 

I would also like to add another column to Table 1 that shows cumulative spend through each period. So on the Period 1 row it would show all spend for Period 1, Period 2 row would show Period 1 + Period 2, etc.

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @sfink22

 

You may create calculated columns as below:

Column =
SUMX (
    FILTER ( 'Table 2', 'Table 2'[Period] = 'Table 1'[Period] ),
    'Table 2'[Amount]
)
Column 2 =
SUMX (
    FILTER ( 'Table 1', 'Table 1'[Period] <= EARLIER ( 'Table 1'[Period] ) ),
    'Table 1'[Column]
)

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
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

3 REPLIES 3
v-cherch-msft
Employee
Employee

Hi @sfink22

 

You may create calculated columns as below:

Column =
SUMX (
    FILTER ( 'Table 2', 'Table 2'[Period] = 'Table 1'[Period] ),
    'Table 2'[Amount]
)
Column 2 =
SUMX (
    FILTER ( 'Table 1', 'Table 1'[Period] <= EARLIER ( 'Table 1'[Period] ) ),
    'Table 1'[Column]
)

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello All,

 

I have the similar requirements, but i wanted to use DAX measure to calculate the total sum (335). Can you please help me in getting desired result by using DAX measure.

Appreciate any suggestions/tips!!

@v-cherch-msft thank you so much! The formulas above both worked perfectly!

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.