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

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

Reply
MigWare
Helper I
Helper I

Aggregate and calculate two different columns

Hi,

 

I´ve two columns, material type and sales data. I need to show all the sales data that falls under material type X, Z, Y and material type A, B, C and R and so on...... basically i need to aggregate the sales data by diferent material types. How can this be achieved.

 

Tks,

1 ACCEPTED SOLUTION

Hi,

 

You can easily add other new custom category to the original formula by IF function, like this:

New_Category =
IF (
    'Table'[Category]
        IN { "Hi-Energy GNA 98", "SPB95 Hi-Energy", "SPB98 Hi-Energy" },
    "Petrol",
    IF ( 'Table'[Category] IN { "A", "B", "C" }, "Gas", 'Table'[Category] )
)

 

Best Regards,

Giotto

View solution in original post

12 REPLIES 12
az38
Community Champion
Community Champion

Hi @MigWare 

based on your poor requirement I see 2 measures as asolution:

Measure = CALCULATE(SUM(Table[sales]), ALLEXCEPT(Table, Table[Material]))

or

Measure = CALCULATE(SUM(Table[sales]), FILTER(ALL(Table), Table[Material] IN {"X", "Z", "Y"} ))

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38 ,

 

Thanks for the input, however i might not have totally clear on the objective. I want to aggregate HI Energy GNA98, SPB95 Hi-Energy and SPB98 HI Energy into one category, like Petrol and show the sum of the values of all those products under one single entity ( Petrol). So I have the date on one axis, the sales on the other and the product description on the legend

 

 
 

image.png

az38
Community Champion
Community Champion

Hi @MigWare 

see this technique

https://docs.microsoft.com/en-us/power-bi/desktop-grouping-and-binning


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi,

 

That option is not available, greyed out. Any other ideia?

 

image.png

 

Hi,

 

Please try to create this calculated column:

New_Category = 
IF (
    'Table'[Category]
        IN { "Hi-Energy GNA 98", "SPB95 Hi-Energy", "SPB98 Hi-Energy" },
    "Petrol",
    'Table'[Category]
)

Then choose this new category column as Legend field, the result shows:

5.PNG

See my attached pbix file.

 

Best Regards,

Giotto

Hi,

 

Thanks for providing that solution, however when I change the table fields to match my data I´m getting the following error:

 

A single value for column 'Product Description' in table 'Master' 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.

Hi,

 

Please try to create a calculated column rather than a measure.

Please check my previous reply again.

Thanks!

 

Best Regards,

Giotto

Hi @v-gizhi-msft,

 

Thanks, I had already figured that out and it worked however I´m just able to create one aggregation. So currently i´m aggregating 3 itens into one "Petrol" but i would need to aggregate the other 3 into another category "Gas". How is that possible?

 

Regards,

Hi,

 

You can easily add other new custom category to the original formula by IF function, like this:

New_Category =
IF (
    'Table'[Category]
        IN { "Hi-Energy GNA 98", "SPB95 Hi-Energy", "SPB98 Hi-Energy" },
    "Petrol",
    IF ( 'Table'[Category] IN { "A", "B", "C" }, "Gas", 'Table'[Category] )
)

 

Best Regards,

Giotto

VijayP
Super User
Super User

Question is not clear can you share some example scenario like showing table etc




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


i want to aggregate ABCD under one single name, like Shirts, and show the sum of those sales number

Material

Sales
A1000
B5000
C6000
D9000
E3000
F7000
G4000
A4000
B5999
C3534
D4324
E525
F5253
G5235
A23432

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.