• 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

Dynamic array formula (group by)|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / Dynamic array formula (group by)|General Excel Questions & Answers|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 ForumGeneral Excel Questions & Answe…Dynamic array formula (group by)
sp_PrintTopic sp_TopicIcon
Dynamic array formula (group by)
Avatar
austris bahanovskis
Member
Members
Level 0
Forum Posts: 14
Member Since:
July 13, 2021
sp_UserOfflineSmall Offline
1
March 1, 2023 - 10:12 pm
sp_Permalink sp_Print

Hi all again,

Last week I received a brilliant help here and hence I'm reaching out once again.

Still to do with dynamic/spill array formulas.

The scenario - there are data in variable number of rows and some rows have 'duplicate' ids in them and I need to construct a dynamic array formula that for each of the unique ID would return their corresponding multiple DISTINCT values concatenated to one value per row/column.

For instance - source:

ID Name City
1 John Toronto
2 Adam Paris
1 John London
3 Ana Madrid
1 James Toronto
3 Ana Rome

and the result then would be - because ID=1 has 2 distinct names, 2 distinct cities, ID=2 has only one unique name & city, and ID=3 has 1 distinct name and 2 distinct cities. later on I'll need to make the columns also dynamic, i.e., sometimes I'd need only ID & Name, sometimes just ID & City, but that's the next level - for now I just need to get the 'grouping' to work. My problem is that whenever I tried to chuck 'filter' into =byrow, it fails...

ID Name City
1 John;James Toronto;London
2 Adam Paris
3 Ana Madrid;Rome

It would be fantastic if again you could help me out here!

sp_AnswersTopicSeeAnswer See Answer
Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 613
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
2
March 1, 2023 - 10:39 pm
sp_Permalink sp_Print

What is the source data - a spill range (or several), regular range, or table?

Avatar
Janset Beyaz

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
February 25, 2023
sp_UserOfflineSmall Offline
3
March 2, 2023 - 3:31 am
sp_Permalink sp_Print

Hi,

Assuming your data is in the range A1:C7

Name and City / Formula - E2

=REDUCE(A1:C1,UNIQUE(A2:A7),LAMBDA(x,y,VSTACK(x,LET(f,FILTER(A2:C7,A2:A7=y),HSTACK(y,TEXTJOIN(", ",,UNIQUE(INDEX(f,,2))),TEXTJOIN(", ",,UNIQUE(INDEX(f,,3))))))))

ID Name City
1 John, James Toronto, London
2 Adam Paris
3 Ana Madrid, Rome
Only City / Formula - E8

=REDUCE({"ID","City"},UNIQUE(A2:A7),LAMBDA(x,y,VSTACK(x,LET(f,FILTER(A2:C7,A2:A7=y),HSTACK(y,TEXTJOIN(", ",,UNIQUE(INDEX(f,,3))))))))

ID City
1 Toronto, London
2 Paris
3 Madrid, Rome
sp_AnswersTopicAnswer
Answers Post

The following users say thank you to Janset Beyaz for this useful post:

Velouria
Avatar
austris bahanovskis
Member
Members
Level 0
Forum Posts: 14
Member Since:
July 13, 2021
sp_UserOfflineSmall Offline
4
March 2, 2023 - 8:03 pm
sp_Permalink sp_Print

Guys - you blow my mind yet again!!

Brilliant - thanks!

Sorry Velouria - I should have specified that - for now it's a table but perhaps it might change to become a spill range but as it's stands it's a table.

Avatar
Janset Beyaz

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
February 25, 2023
sp_UserOfflineSmall Offline
5
March 3, 2023 - 9:25 am
sp_Permalink sp_Print

@Velouria, many thanks...

@austris bahanovskis, glad to have helped and thanks for your feedback

Avatar
Alan Sidman
Steamboat Springs, CO
Member
Members


Trusted Members
Level 0
Forum Posts: 130
Member Since:
October 18, 2018
sp_UserOfflineSmall Offline
6
March 4, 2023 - 2:54 am
sp_Permalink sp_Print

I would use a different approach.  With Power Pivot, build a measure to concatenate the values.  

ie.  =CONCATENATEX(Range,Range[Name],", ")

 

You can see the results in the Pivot Table in the file attached

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Ivica Cvetkovski
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:
Ivica Cvetkovski
Blaine Cox
Shankar Srinivasan
riyepa fdgf
Hannah Cave
Len Matthews
Kristine Arthy
Michelle Neven
Andrew Kuhn
Angela Paul
Forum Stats:
Groups: 3
Forums: 24
Topics: 6206
Posts: 27202

 

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