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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Sum multiple Columns formula

Hello,

 

I would like to sum mutliple columns in a table. For now, I simply did it like this:

JTR_0-1636970421669.png

As the amount of columns might vary from time to time, I aim to make it more flexible. In all columns that have to be summed the word "Capacity" will always appear in the first row. Is it possible to create a Column based on a formula in the Power Query Editor which automatically sums all Columns which have the word capacity in its first row?

 

Thank you very much for your help.

 

Best regards,

Jakob

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Can you promote the first row as header or you need the column names remain as Column1, Column2...? Here is one way if you promote the first row, my previous step is Change Type, you need to modify it accordingly

 

Vera_33_0-1636985363544.png

 

Table.AddColumn(yourPreviousStep, "Custom", (x) => List.Sum(List.Transform( List.Select( Table.ColumnNames( yourPreviousStep), each Text.Contains(_,"Capacity")), each Record.Field(x,_))))

 

View solution in original post

2 REPLIES 2
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Can you promote the first row as header or you need the column names remain as Column1, Column2...? Here is one way if you promote the first row, my previous step is Change Type, you need to modify it accordingly

 

Vera_33_0-1636985363544.png

 

Table.AddColumn(yourPreviousStep, "Custom", (x) => List.Sum(List.Transform( List.Select( Table.ColumnNames( yourPreviousStep), each Text.Contains(_,"Capacity")), each Record.Field(x,_))))

 

Anonymous
Not applicable

It works like this, thank you very much!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors