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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
TKray23
Regular Visitor

Need help to calculate the sum from different columns depending on the filter value

I Need help to calculate the sum from different columns depending on the filter value
I have two tables 
Table1 has a column Col V with different values: a,b,c,
Table 2 has many columns and rows. Some of the columns are used as flags and have values 1 and 0. Lets say Col1, Col2, Col3
 
Table1 ColV is used as a filter on the page
I need to be able to calculate the sum  of one of the Table2 Columns( Col1, Col2, Col3) depending on the value of the Table1 ColV
 
Lets say
 
Table1 ColV= a
Than SUM of Flags= Sum of Col1
 
If 
 
Table1 ColV= b
Than SUM of Flags=Sum of Col2
 
if
 
Table1 ColV= c
Than SUM of Flags=Sum of Col3
1 ACCEPTED SOLUTION
CoreyP
Solution Sage
Solution Sage

I think I understand now. Maybe a SWITCH function? Like..

Sum Of Flags = 
VAR A_flags = SUM( 'Table2'[Col1] )
VAR B_flags = SUM( 'Table2'[Col2] )
VAR C_flags = SUM( 'Table2'[Col3] )
VAR ColV_filter = MAX( 'Table1'[ColV] )

RETURN
SWITCH(
TRUE() , 
ColV_filter = "A" , A_flags ,
ColV_filter = "B" , B_flags ,
ColV_filter = "C" , C_flags ,
BLANK()
)

View solution in original post

4 REPLIES 4
CoreyP
Solution Sage
Solution Sage

I think I understand now. Maybe a SWITCH function? Like..

Sum Of Flags = 
VAR A_flags = SUM( 'Table2'[Col1] )
VAR B_flags = SUM( 'Table2'[Col2] )
VAR C_flags = SUM( 'Table2'[Col3] )
VAR ColV_filter = MAX( 'Table1'[ColV] )

RETURN
SWITCH(
TRUE() , 
ColV_filter = "A" , A_flags ,
ColV_filter = "B" , B_flags ,
ColV_filter = "C" , C_flags ,
BLANK()
)

Hi, Thank you for your assistance!

CoreyP
Solution Sage
Solution Sage

Is there a relationship between the two tables?

yes, many to many

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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