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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
R3mi
New Member

Sum by customer but without grouping / total sales per customer

Hey !

I need a little help for something I thought it would be simple but I'm getting stuck  😅 .

I have a table where each row represents an order line with a product code, the price and quantity per customer it look like this : 

CustomNumberOrderNumberProductNumberQtyPrice
001001001111100
001001001122200
002002001111100
002002001121200
002002002131300
002002002142400

 

Now I need a new column with the total sale per customer, but I don't want to use the group by customer method because I need to keep each row for another step.
I want something like this :

CustomNumberOrderNumberProductNumberQtyPriceTotal per customer
001001001111100500
001001001122200500
0020020011111001400
0020020011212001400
0020020021313001400
0020020021424001400


So first I have created a new column with the Total per product (Price x Qty) but now i'm struggle and can't find a formula without group per customer...
Maybe I need to create another request ? an then add both ?
Thanks  !

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

Hi, @R3mi add Price x Qty, group by customer (sum new column and retain all columns), then expand missing columns. Table.Group is your friend. 

let
    Source = your_table,
    ttl_prod = Table.AddColumn(Source, "total_product", each [Qty] * [Price]),
    group = Table.Group(
        ttl_prod, "CustomNumber", 
        {{"all", each _}, 
        {"Total per customer", each List.Sum([total_product])}}
    ),
    expand = Table.ExpandTableColumn(group, "all", {"OrderNumber", "ProductNumber", "Qty", "Price"})
in
    expand

View solution in original post

2 REPLIES 2
AlienSx
Super User
Super User

Hi, @R3mi add Price x Qty, group by customer (sum new column and retain all columns), then expand missing columns. Table.Group is your friend. 

let
    Source = your_table,
    ttl_prod = Table.AddColumn(Source, "total_product", each [Qty] * [Price]),
    group = Table.Group(
        ttl_prod, "CustomNumber", 
        {{"all", each _}, 
        {"Total per customer", each List.Sum([total_product])}}
    ),
    expand = Table.ExpandTableColumn(group, "all", {"OrderNumber", "ProductNumber", "Qty", "Price"})
in
    expand

Thanks !

I just missed the last step "expand" ... so simple 😅

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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