• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Sum with Dynamic Column List|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Sum with Dynamic Column List|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QuerySum with Dynamic Column List
sp_PrintTopic sp_TopicIcon
Sum with Dynamic Column List
Avatar
Tanya McIlravy
Member
Members
Level 0
Forum Posts: 11
Member Since:
September 29, 2021
sp_UserOfflineSmall Offline
1
March 20, 2022 - 5:29 am
sp_Permalink sp_Print

I need to add columns that sum based on column name. The columns present may vary but will be 4 digit codes (GL account numbers).

I have a solution that requires unpivot and merge for each combination, but I have six combinations and 60K rows so I am looking for a way to do it with lists instead in hopes of improved performance.

I need to get a list for the List.Sum function as a list rather than as text.

Example: Sum values by row for all columns that start with 47 and end in 1 (47x1 column)

Not dynamic: = Table.AddColumn(Source, "Addition", each List.Sum({[4701], [4721], [4751]}), type number)

I can get a dynamic list in a step to call, but it brings in text values "4701", "4751", "4781" rather than [4701], [4751], [4781] format for the List.Sum to accept it.

I can't find a way to convert a list from text into just a string of values.

I attached a sample data with hard coded examples. Any suggestions for how to do this with lists/efficiently, would be appreciated. Thanks.

sp_AnswersTopicSeeAnswer See Answer
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 440
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
2
March 20, 2022 - 7:29 pm
sp_Permalink sp_Print sp_EditHistory

You didn't attach a file but I believe it was clear what you needed.

Google a bit and come to this site:

https://www.bookkempt.com/2019.....power.html

Used the method described to construct the attached file and learned a great deal from it myself. Perhaps you can use it in your own.

sp_AnswersTopicAnswer
Answers Post
Avatar
Tanya McIlravy
Member
Members
Level 0
Forum Posts: 11
Member Since:
September 29, 2021
sp_UserOfflineSmall Offline
3
March 21, 2022 - 5:46 am
sp_Permalink sp_Print

Thank you! I thought I had attached a file! I appreciate your reply and am headed to check it out!

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 613
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
4
March 22, 2022 - 7:30 am
sp_Permalink sp_Print

With a list of matching column names, you can get the sum using something like:

List.Sum(Record.ToList(Record.SelectFields(_, MatchingColumnNames)))

Avatar
Tanya McIlravy
Member
Members
Level 0
Forum Posts: 11
Member Since:
September 29, 2021
sp_UserOfflineSmall Offline
5
March 23, 2022 - 12:47 am
sp_Permalink sp_Print

Thank you Velouria. I can't mark two answers 🙁

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 613
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
6
March 23, 2022 - 1:59 am
sp_Permalink sp_Print

No problem - just wanted to mention it as an alternative. 🙂

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Janset Beyaz
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
wahab tunde
Cong Le Duc
Faisal Bashir
Ivica Cvetkovski
Blaine Cox
Shankar Srinivasan
riyepa fdgf
Hannah Cave
Len Matthews
Kristine Arthy
Forum Stats:
Groups: 3
Forums: 24
Topics: 6205
Posts: 27209

 

Member Stats:
Guest Posters: 49
Members: 31878
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.