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
leodavinci
Regular Visitor

Summarize table based on sum of a column

Hello, 

 

in Power BI desktop I'm trying to summarize the table below.

The result I want is a table with only one ID and the related Brand with the highest quantity (obtained by summing up all the quantity for the same Brand on each ID).

 

imagebi.JPG

 

I tried to create a calculated table with the formula below, but rhe result is not correct.

 

Table2 =

SUMMARIZE(Table1,

Table1[ID],

Table1[Brand],

"TotalQuantity",

SUMX(Table1, Table1[Quantity])

)


I'd be greatful if someone could suggest a better formula or different method.
1 ACCEPTED SOLUTION
v-weiyan1-msft
Community Support
Community Support

Hi @leodavinci ,

 

Based on your description,
Please try the following steps:
My Sample:

vweiyan1msft_0-1705487967521.png

1. Please try code as below to Create a Calculated table.

GroupTable = GROUPBY (
    'Table',
    'Table'[ID],
    'Table'[Brand],
    "@Quantity", SUMX(CURRENTGROUP(), 'Table'[Quantity])
)

2. Use the following code to create two Measures.

Max_Quantity = MAXX(
                    FILTER(ALL(GroupTable),'GroupTable'[Table_ID] = MAX('GroupTable'[Table_ID])),
                    'GroupTable'[@Quantity]
                )
Max_Quantity_Corresponding Brand = MAXX(FILTER(ALL(GroupTable),
                                        'GroupTable'[@Quantity] = [Max_Quantity] && 'GroupTable'[Table_ID] = MAX('GroupTable'[Table_ID])) 
                                        ,'GroupTable'[Table_Brand])

Result is as below.

vweiyan1msft_1-1705488178562.png

 

Best Regards,
Yulia Yan

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-weiyan1-msft
Community Support
Community Support

Hi @leodavinci ,

 

Based on your description,
Please try the following steps:
My Sample:

vweiyan1msft_0-1705487967521.png

1. Please try code as below to Create a Calculated table.

GroupTable = GROUPBY (
    'Table',
    'Table'[ID],
    'Table'[Brand],
    "@Quantity", SUMX(CURRENTGROUP(), 'Table'[Quantity])
)

2. Use the following code to create two Measures.

Max_Quantity = MAXX(
                    FILTER(ALL(GroupTable),'GroupTable'[Table_ID] = MAX('GroupTable'[Table_ID])),
                    'GroupTable'[@Quantity]
                )
Max_Quantity_Corresponding Brand = MAXX(FILTER(ALL(GroupTable),
                                        'GroupTable'[@Quantity] = [Max_Quantity] && 'GroupTable'[Table_ID] = MAX('GroupTable'[Table_ID])) 
                                        ,'GroupTable'[Table_Brand])

Result is as below.

vweiyan1msft_1-1705488178562.png

 

Best Regards,
Yulia Yan

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ray_aramburo
Super User
Super User

Do you need the table explicitly on your dataset? If so, just go to Power Query > Group By > Select ID, Brand columns and group by sum of quantity.

If not, just use a table visual and add the fields ID, Brand and Quantity. Power BI will automatically add up the quantity if it's set as a numerical column. 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





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