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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
RPAI2812
Helper I
Helper I

Problem when summing filtered table.

I have two tables that are related by the Flight column. I want to add three new columns to Table 1 with the sum of the percentages each Cost Center has on that specific flight (information that is on Table 2).

 

Table 1

FlightInfo1Info2
Flight1......
Flight2......
Flight3......
.........

 

Table 2

FlightCost CenterPercentage
Flight1CC150%
Flight1CC250%
Flight2CC125%
Flight2CC235%
Flight2CC340%
Flight3CC120%
Flight3CC220%
Flight3CC260%
.........

 

The desired result would be somethink like this below. Please note that sometimes I can have repeated rows of the same Cost Center for a same flight on Table 2 (like on flight 3 where I have CC2 20% + CC2 60% separately).

FlightInfo1Info2CC1CC2CC3
Flight1......50%50%0%
Flight2......25%35%40%
Flight3......20%80%0%
..................


I tried using something like this below, but it returns the total for that specific cost center of all flights together, instead of separetely for each flight with its respective value. I need the sum because sometimes the cost center will repeat for the same flight in Table 2, but not summing everything together..

CC1 = CALCULATE(SUMX('Table 2','Table 2'[Percentage]),FILTER('Table 2','Table 2'[Cost Center]="CC1"))
CC2 = CALCULATE(SUMX('Table 2','Table 2'[Percentage]),FILTER('Table 2','Table 2'[Cost Center]="CC2"))
CC3 = CALCULATE(SUMX('Table 2','Table 2'[Percentage]),FILTER('Table 2','Table 2'[Cost Center]="CC3"))

I thought of using LOOKUPVALUE, but I would need to filter Table 2 and I'm not sure how to use a "Virtual Table" inside LOOKUPVALUE function. At the same time, it would be a problem for when I have repeated cost centers for the same flight on Table 2 as mentioned before, because it would not sum.. it would take the first value it finds. Also tought of using RELATED DAX but I don't think it will work.. I have some ideas, but not sure how to figure it out.

1 ACCEPTED SOLUTION
SteveHailey
Solution Specialist
Solution Specialist

Hello @RPAI2812. I think you may be overcomplicating this one. I loaded your example tables, and created a relationship as follows:

SteveHailey_2-1641590348522.png

 

Then created a simple sum measure and matrix visual as seen below:

SteveHailey_1-1641590288048.png

Here's a link to a PBIX in case it's helpful.

-Steve

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

I agree with @SteveHailey but if you do need a measure or calculated column for CC1 for some reason, this should work (assuming the tables have a relationship on Flight and the calculated column is on Table 1):

CALCULATE ( SUM ('Table 2'[Percentage] ), 'Table 2'[Cost Center] = "CC1" )
SteveHailey
Solution Specialist
Solution Specialist

Hello @RPAI2812. I think you may be overcomplicating this one. I loaded your example tables, and created a relationship as follows:

SteveHailey_2-1641590348522.png

 

Then created a simple sum measure and matrix visual as seen below:

SteveHailey_1-1641590288048.png

Here's a link to a PBIX in case it's helpful.

-Steve

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors