cancel
Showing results 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.

Helper I

## Create a measure to calculate SUM from two different table

Hi, I'll try my best to explain what I need to solve my problem. I have two tables (table1, table2) below. I have a created a relationship between the two tables using the location column. I'm using a stacked bar chart for the visual. What is the best approach to get the right result? Thanks for all your help!

Table 1

 Location Name Capacity A Apple 100 B Orange 75 C Banana 95 D Pear 100

Table 2

 Location # of Volunteers A 56 B 15 C 42 D 50

3 ACCEPTED SOLUTIONS
Community Champion

Create a New Measure: Open the Power BI Desktop, go to the modeling tab, and click on "New Measure". Then, use the following DAX expression:

Total Capacity = SUM('Table1'[Capacity])

1. This measure will give you the total capacity from Table1.

2. Create Another Measure: Similarly, create a measure for the total number of volunteers:

Total Volunteers = SUM('Table2'[# of Volunteers])

1. This measure will give you the total number of volunteers from Table2.

2. Create a Stacked Bar Chart: Now, you can use these measures in your stacked bar chart. Place the "Location" field from either Table1 or Table2 on the axis, and then add the "Total Capacity" and "Total Volunteers" measures to the Values section of the chart.

This will give you a visual representation of the total capacity and total number of volunteers for each location.

In summary, the key is to create measures that calculate the total capacity and total number of volunteers separately for each table and then use these measures in your visualizations.

OR

##### Total Capacity = SUMX(table1,table1[Capacity]) + SUMX(table2,table2[# of Volunteers])

This measure will sum the Capacity column from table1 and the # of Volunteers column from table2. The SUMX function iterates over each row of the table and returns the sum of the expression for each row. In this case, the expression is simply the name of the column we want to sum.

I hope this helps! Let me know if you have any other questions.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Community Support

Hi, @mason23

Maybe there is no need to create measure.

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helper I

Thank you for your quick response. I tried both methods and it worked.

3 REPLIES 3
Helper I

Thank you for your quick response. I tried both methods and it worked.

Community Support

Hi, @mason23

Maybe there is no need to create measure.

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Champion

Create a New Measure: Open the Power BI Desktop, go to the modeling tab, and click on "New Measure". Then, use the following DAX expression:

Total Capacity = SUM('Table1'[Capacity])

1. This measure will give you the total capacity from Table1.

2. Create Another Measure: Similarly, create a measure for the total number of volunteers:

Total Volunteers = SUM('Table2'[# of Volunteers])

1. This measure will give you the total number of volunteers from Table2.

2. Create a Stacked Bar Chart: Now, you can use these measures in your stacked bar chart. Place the "Location" field from either Table1 or Table2 on the axis, and then add the "Total Capacity" and "Total Volunteers" measures to the Values section of the chart.

This will give you a visual representation of the total capacity and total number of volunteers for each location.

In summary, the key is to create measures that calculate the total capacity and total number of volunteers separately for each table and then use these measures in your visualizations.

OR

##### Total Capacity = SUMX(table1,table1[Capacity]) + SUMX(table2,table2[# of Volunteers])

This measure will sum the Capacity column from table1 and the # of Volunteers column from table2. The SUMX function iterates over each row of the table and returns the sum of the expression for each row. In this case, the expression is simply the name of the column we want to sum.

I hope this helps! Let me know if you have any other questions.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Announcements

#### 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

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors