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
vidyasagar159
Helper II
Helper II

Aggregating multiple columns based on category filter

Hello All,

 

Aggressively learning Power BI and doing a project at the same time. But I am stuck on a logic. Please help. 

I want to Subtract two columns based on the Conditional Aggregation.PNGProduct category. I want to achieve the below result set. 

 

 

 

 

 

 

Here is the logic I am looking for 
IF Category = Red then (Amount_One) - (Amount_Two) else if Category = Black then (Amount_One) - (Amount_Three)

 

ProductCategoryAmount_OneAmount_TwoAmount_ThreeIF Category = Red then (Amount_One) - (Amount_Two) else if Category = Black then (Amount_One) - (Amount_Three)
ARed100109090
ARed2002080180
ARed3003070270
ARed4004060360
ARed5005050450
ARed6006040540
BBlack7007030670
BBlack8008020780
BBlack9009010890
BBlack100010001000
BBlack1100110-101110
BBlack1200120-201220

Thanks,

Vidya

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @vidyasagar159 

 

 

IF(Table1[Category] = “Red”, [Amount_One]-[Amount_Two], [Amount_One]-[Amount_Three]]

 

 

Best, 
Paul

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @vidyasagar159 

 

 

IF(Table1[Category] = “Red”, [Amount_One]-[Amount_Two], [Amount_One]-[Amount_Three]]

 

 

Best, 
Paul

@Anonymous 

Thanks. But I am getting the following error.

 

A single value for column 'Category' in table 'Table1' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

 

Thanks,

-Vidya

@Anonymous 

 

Never Mind. It is working. I used the formula in a measure instead of a calculated column. Thank you for your help.

 

-Vidya

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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