• 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

UNIQUE values from two sources|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / UNIQUE values from two sources|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…UNIQUE values from two sources
sp_PrintTopic sp_TopicIcon
UNIQUE values from two sources
Avatar
jab che
Member
Members
Level 0
Forum Posts: 16
Member Since:
June 25, 2020
sp_UserOfflineSmall Offline
1
November 26, 2020 - 1:13 am
sp_Permalink sp_Print

I have two tables of Broker queries, is it possible to extract a single dynamic list of distinct Brokers without recourse to Power Query?

eg if table1 had Broker1 and Broker2, table2 had Broker2 and Broker3 then I would like to be able to produce a list of Broker1, Broker2 and Broker3 which doesn't need a Refresh to update it

I was hoping something like UNIQUE({table1[Broker];table2[Broker]}) would work (ok with constants but not references)

Kind regards,

jim

sp_AnswersTopicSeeAnswer See Answer
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4449
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
November 26, 2020 - 10:11 pm
sp_Permalink sp_Print

Hi Jim,

You can use this formula by fellow Excel MVP, Ismael Romero:

=UNIQUE(LET(
ranges, (A2:A4,C2:C4,E2:E4),
areas, AREAS((A2:A4,C2:C4,E2:E4)),
rows, ROWS(A2:A4),
TotalRows, SEQUENCE(areas*rows),
NumArea, CEILING.MATH(SEQUENCE(areas*rows),rows)/rows,
Row, TotalRows-(NumArea-1)*rows,
INDEX(ranges,Row,1,NumArea)))

See file attached.

Mynda
Avatar
jab che
Member
Members
Level 0
Forum Posts: 16
Member Since:
June 25, 2020
sp_UserOfflineSmall Offline
3
November 27, 2020 - 2:08 am
sp_Permalink sp_Print sp_EditHistory

Thanks Mynda,

I knew there would be a straightforward answer 😉

This only seems to work if there are the same number of entries in each list and isn't dynamic for new additions

I won't pretend to know exactly how the above works, but I've modified it a little:

each list of brokers is now a table (tA, tB and tC), I've renamed some of the names used (not keen on them being the same as functions) and introduced an error trap for unequal list lengths

I'm sure Ismael would come up with a much better solution but this formula now works perfectly for my needs:

=UNIQUE(LET(
rRanges, (tA[Broker],tB[Broker],tC[Broker]),
cAreas, AREAS(rRanges),
cRows, MAX(ROWS(tA),ROWS(tB),ROWS(tC)),
TotalRows, SEQUENCE(cAreas*cRows),
NumArea, CEILING.MATH(SEQUENCE(cAreas*cRows),cRows)/cRows,
cRow, TotalRows-(NumArea-1)*cRows,
IFERROR(INDEX(rRanges,cRow,,NumArea),INDEX(tA,1,1))))

thank you both for your time and attention

 

jim

PS without the LET function, this expands to a nightmarish:
=UNIQUE(IFERROR(INDEX((tA[Broker],tB[Broker],tC[Broker]),SEQUENCE(AREAS((tA[Broker],tB[Broker],tC[Broker]))*MAX(ROWS(tA),ROWS(tB),ROWS(tC)))-(CEILING.MATH(SEQUENCE(AREAS((tA[Broker],tB[Broker],tC[Broker]))*MAX(ROWS(tA),ROWS(tB),ROWS(tC))),MAX(ROWS(tA),ROWS(tB),ROWS(tC)))/MAX(ROWS(tA),ROWS(tB),ROWS(tC))-1)*MAX(ROWS(tA),ROWS(tB),ROWS(tC)),,CEILING.MATH(SEQUENCE(AREAS((tA[Broker],tB[Broker],tC[Broker]))*MAX(ROWS(tA),ROWS(tB),ROWS(tC))),MAX(ROWS(tA),ROWS(tB),ROWS(tC)))/MAX(ROWS(tA),ROWS(tB),ROWS(tC))),INDEX(tA,1,1)))

named ranges could be used but then it wouldn't be as portable, so I'm very grateful for LET

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4449
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
4
November 27, 2020 - 2:20 pm
sp_Permalink sp_Print

Nice modification, Jim! Thanks for sharing.

Avatar
jab che
Member
Members
Level 0
Forum Posts: 16
Member Since:
June 25, 2020
sp_UserOfflineSmall Offline
5
November 27, 2020 - 10:21 pm
sp_Permalink sp_Print sp_EditHistory

I found Ismael's post and the linked source article by Mourad Louha which laid out the logic behind it and, now that I understand it a little better, I've found a simpler solution

NB this only works for 2 sources - which suits my requirements but, if required for more than 2, then it can be extended but I think I'd use the solution above for more than 3, which uses the "area" version of INDEX (and which I still don't totally follow)
I've also tried to use better names and spacing to ease understanding (the two original tables are now tabA and tabB)

=UNIQUE(LET( datA, tabA[Broker],  datB, tabB[Broker],
  numA, ROWS(datA),  numB, ROWS(datB),
  seqR, SEQUENCE(numA+numB),
IF(seqR<=numA, INDEX(datA,), INDEX(datB,seqR-numA))))

without LET, this is much simpler than before:
=UNIQUE(IF(SEQUENCE(ROWS(tabA)+ROWS(tabB)) <= ROWS(tabA),
    INDEX(tabA[Broker],),
    INDEX(tabB[Broker], SEQUENCE(ROWS(tabA)+ROWS(tabB),,1-ROWS(tabA)))))

jim

sp_AnswersTopicAnswer
Answers Post
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4449
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
6
November 28, 2020 - 2:27 pm
sp_Permalink sp_Print

Thanks so much for sharing, Jim! Shorter is always nicer 🙂 ...as long as it's not slower of course.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Kim Knox
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 204
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Bhuwan Devkota
Kathryn Patton
Maria Conatser
Jefferson Granemann
Glen Coulthard
Nikki Fox
Rachele Dickie
Raj Mattoo
Mark Luke
terimeri dooriyan
Forum Stats:
Groups: 3
Forums: 24
Topics: 6221
Posts: 27285

 

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