• 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

Dynamically creating concatenated column |Power Query|Excel Forum|My Online Training Hub

You are here: Home / Dynamically creating concatenated column |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 QueryDynamically creating concatenated c…
sp_PrintTopic sp_TopicIcon
Dynamically creating concatenated column
Avatar
jaryszek
Member
Members
Level 0
Forum Posts: 183
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline
1
February 24, 2021 - 8:59 pm
sp_Permalink sp_Print sp_EditHistory

Hello Guys,

i have table :

Screenshot_128.pngImage Enlarger

And now i am building Table1 query where i want to add additional custom - concatenated columns based on ListOfTables table. 

Screenshot_129.pngImage Enlarger


As you can see concatenation column (Key) is made only from Col1&Col2&Col3 because in ListOfTables table there is no more Concatenated colums listed for the specific table. 

How to build dynamic solution for the issue?

It would be nice to create a dynamic list based on Table name from ListOfTables and matching columns from used table, in our example Table1. 

In Other words, 
How to dynamically add Key column concatenated with columns listed in ListOfTables into specific query? 

Please help,
Jacek

sp_PlupAttachments Attachments
  • sp_PlupImage Screenshot_128.png (199 KB)
  • sp_PlupImage Screenshot_129.png (147 KB)
sp_AnswersTopicSeeAnswer See Answer
Avatar
jaryszek
Member
Members
Level 0
Forum Posts: 183
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline
2
February 25, 2021 - 6:10 pm
sp_Permalink sp_Print

Anyone can help?

Best,
Jacek

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
3
February 25, 2021 - 10:06 pm
sp_Permalink sp_Print

Hi Jacek,

I don't really understand what you are trying to do.

Can you try to explain it again with some real tables and columns?

Regards

Phil

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4446
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
4
February 26, 2021 - 9:13 am
sp_Permalink sp_Print

Hi Jacek,

I think the problem with the example is that the data in the columns is the same as the column headers. It's also not clear whether you want to refer to column numbers or real column names because the example uses column names with numbers.

Perhaps some more realistic example data will help us infer what you really want. It would also be good to have some background information on why you want to do this as the solution you're requesting might not be the most efficient.

Mynda

Avatar
jaryszek
Member
Members
Level 0
Forum Posts: 183
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline
5
February 26, 2021 - 7:51 pm
sp_Permalink sp_Print

Hi Guys,

thank you.
All what i need is to refer to column names and use them dynamically in concatenation column. 

So instead of writing manually string in concatenated formula: "=[Col1] & "-" & [Col2] & "-" & [Col3]" i want to create list of column names dynamically and use the list in concatenated formula to not do this manually. 

I hope it is clear now.

So how to provide dynamic list from table header names in order to use them in a list in concatenated formula syntax?

please ask if something is not understandable. 

Best,
Jacek

Avatar
jaryszek
Member
Members
Level 0
Forum Posts: 183
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline
6
March 1, 2021 - 3:16 pm
sp_Permalink sp_Print

Anyone can help?

Best,
Jacek

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 615
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
7
March 2, 2021 - 2:53 am
sp_Permalink sp_Print

I'd imagine this can be simplified, but it's been a long day!

 

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Col1", type text}, {"Col2", type text}, {"Col3", type text}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type", "TableName", each "Table1"),
#"Merged Queries" = Table.NestedJoin(#"Added Custom1",{"TableName"},ListOfTables,{"TableName"},"ListOfTables",JoinKind.LeftOuter),
#"Added Custom" = Table.AddColumn(#"Merged Queries", "Key", each Table.ToList(Table.SelectColumns([ListOfTables], {"ColumnsToConcatenate"}))),
#"Added Custom2" = Table.AddColumn(#"Added Custom", "Custom", each Text.Combine(Record.FieldValues(Record.SelectFields(_, [Key])), ","))
in
#"Added Custom2"

sp_AnswersTopicAnswer
Answers Post
Avatar
jaryszek
Member
Members
Level 0
Forum Posts: 183
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline
8
March 2, 2021 - 6:15 pm
sp_Permalink sp_Print

O wow this is awesome! 

Working like a charm, thank you so much!

Best,
Jacek

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Ruth Savage, Andy Kirby, Roy Lutke, Jeff Krueger
Guest(s) 9
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:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31889
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.