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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors