Skip to main content
cancel
Showing results for 
Search instead 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.

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
V-pazhen-msft
Community Support
Community Support

Hi, @vidyasagar159 

 

 

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

 

 

Best, 
Paul

View solution in original post

3 REPLIES 3
V-pazhen-msft
Community Support
Community Support

Hi, @vidyasagar159 

 

 

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

 

 

Best, 
Paul

@V-pazhen-msft 

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

@V-pazhen-msft 

 

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
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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