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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Einomi
Helper V
Helper V

Sum certain columns

Hi,

 

Very common topic, but I cannot find an easy and proper solution. I have data coming and I applied some transformations to unpivot the data. As a result, I have 7 columns (the 7 first) that give me details on the order. and all the other columns (up to 90 columns) are the product they ordered (in the headers the name of the product, in the cell the quantity)

 

I would like to add a column that gives me the total quantity of the products ordered. Obviously dynamically. I found some codes online. This one work but it does not add a column with the quantity rather a table with all my data unpivoted and a sum column...

 

let
    Source = Consolidation,
    #"Colonnes supprimées" = Table.RemoveColumns(Source,{"What is your e-mail address ?", "Loyalty Card", "Card Number"}),
    #"Espaces supprimés" = Table.TransformColumns(#"Colonnes supprimées",{{"City", Text.Trim, type text}}),
    #"Personnalisée ajoutée" = Table.AddColumn(#"Espaces supprimés", "Personnalisé", each 
    let  
        FirstColRef = 7,
        NumColsToSum = Table.ColumnCount(#"Colonnes supprimées")-FirstColRef,
        RowTotal = Table.AddColumn(#"Colonnes supprimées", "Sum", each List.Sum(List.Range(Record.ToList(_),FirstColRef,NumColsToSum)))
    in    
        RowTotal
        
        )
in
    #"Personnalisée ajoutée"

 

Can someone help please ?

2 ACCEPTED SOLUTIONS
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

This would work

let
    Source = Consolidation,
    #"Colonnes supprimées" = Table.RemoveColumns(Source,{"What is your e-mail address ?", "Loyalty Card", "Card Number"}),
    #"Espaces supprimés" = Table.TransformColumns(#"Colonnes supprimées",{{"City", Text.Trim, type text}}),
    FirstColRef = 7,
    RowTotal = Table.AddColumn(#"Colonnes supprimées", "Sum", each List.Sum(List.Skip(Record.ToList(_),FirstColRef)))
    in    
        RowTotal

View solution in original post

Einomi
Helper V
Helper V

2 REPLIES 2
Einomi
Helper V
Helper V

Thank You, perfect @Vijay_A_Verma 

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

This would work

let
    Source = Consolidation,
    #"Colonnes supprimées" = Table.RemoveColumns(Source,{"What is your e-mail address ?", "Loyalty Card", "Card Number"}),
    #"Espaces supprimés" = Table.TransformColumns(#"Colonnes supprimées",{{"City", Text.Trim, type text}}),
    FirstColRef = 7,
    RowTotal = Table.AddColumn(#"Colonnes supprimées", "Sum", each List.Sum(List.Skip(Record.ToList(_),FirstColRef)))
    in    
        RowTotal

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.