+ Reply to Thread
Results 1 to 14 of 14

Matrix or Pivot table or else?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-09-2018
    Location
    Quebec, Canada
    MS-Off Ver
    Office 365
    Posts
    129

    Matrix or Pivot table or else?

    Hello Forum,

    I have to build a "co-location" Matrix and I am wondering if Excel will save me the manual entry…
    Here is the context: I have a table of around 2000 rows, with 2 columns.
    In the first column, I have adresses, in the second, company names.
    In the end, I need to have a crossed table showing which company colocates with the other, whatever the address they sit at.
    Note: the number of rows per address may be different from an address to the other, depending on the number of companies they accomodate.

    I tried manipulating the data with Pivot tables but I can't seem to catch the thing; and it seems I can't use the company field twice in the same Pivot, in rows and columns.

    In short: I'm stuck.

    I am including an example of what I have and what I need.

    Thank you for your help!
    Attached Files Attached Files

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Matrix or Pivot table or else?

    In your sample, companies 3 and 6 both have Address 4. Why is there not a 1 in cells J4 and H9 of your sample?

    In your sample, there is no Company 5. Why are there 1's in the Company 5 row and column?

    Are your desired results not based off of your sample data? This makes it very confusing for us.

  3. #3
    Forum Contributor
    Join Date
    10-09-2018
    Location
    Quebec, Canada
    MS-Off Ver
    Office 365
    Posts
    129

    Re: Matrix or Pivot table or else?

    I'm sorry I made this example this Morning and started with 10 companies and 10 addresses, but realized that I didn't neet so many items and figured people would understand the picture. Those are just "manual" mistakes that I properly want to avoid by using Excel Tools.
    I downsized my example to three items. I hope I did not make any mistake (early Morning).
    Thank you.
    Attached Files Attached Files

  4. #4
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Matrix or Pivot table or else?

    I couldn't think of any clever way to do this using a single formula or Pivot Table. For now, this is the best that I've got.

    Create a Pivot Table with Address in the ROWS, Company in the COLUMNS, and either one in the VALUES.

    Concatenate all companies for each address. I used this formula in M3:
    =IF(J3="","",J$2)&IF(K3="","",K$2)&IF(L3="","",L$2)
    Drag down column M. Note that this would be scale able with the TEXTJOIN function (if you don't have Office 365 you can create a UDF to replicate it).

    Create your matrix showing all companies going across and down then you can use something like this in E3:
    =IF(AND($D3<>E$2,COUNTIFS($M:$M,"*"&$D3&"*",$M:$M,"*"&E$2&"*")),1,"")
    Drag across and down.

    See attachment.
    Attached Files Attached Files
    Last edited by 63falcondude; 10-19-2018 at 10:11 AM.

  5. #5
    Forum Contributor
    Join Date
    10-09-2018
    Location
    Quebec, Canada
    MS-Off Ver
    Office 365
    Posts
    129

    Re: Matrix or Pivot table or else?

    Thank you very much Falcondude, this is a really good start.

    My only concern is that I have 37 companies to take into account and I can't insert 37 "if" in the formula, unless there is a way to skip the blank cells… ?

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Matrix or Pivot table or else?

    Here is a better (more scaleable) method using Power Query.

    If you like this method, I can walk you through the process.

    I followed this.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    10-09-2018
    Location
    Quebec, Canada
    MS-Off Ver
    Office 365
    Posts
    129

    Re: Matrix or Pivot table or else?

    I just looked up Power Query and understand that I have to download it. Unfortunately, computers in our company are seriously restricted and downloading anything is impossible. We have to work with the authorized applications.

    Maybe I can use Access if we talk about queries?

  8. #8
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Matrix or Pivot table or else?

    We have to work with the authorized applications.
    The cool thing about Power Query is that it is a built-in Excel functionality (starting with Excel 2016) that you can find in the Data tab.

    If you have 2013, it can be downloaded as an Excel add-in right from the Microsoft website.

    Maybe I can use Access if we talk about queries?
    Maybe... but I can't help there.

    If you want to create a UDF for the TEXTJOIN function to replace the multiple IFs, we can go down that route.
    Last edited by 63falcondude; 10-19-2018 at 10:57 AM.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,140

    Re: Matrix or Pivot table or else?

    A UDF will require the workbook to be saved as macro-enabled - will that be allowed in Sybille's company? Probably not.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  10. #10
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Matrix or Pivot table or else?

    A UDF will require the workbook to be saved as macro-enabled
    Unless this is a one-time task.

    will that be allowed in Sybille's company? Probably not.
    I have no idea. My company has restrictions on emailing macro enabled workbooks but not saving or opening them.

    That being said, this is one of the reasons why I try to stay away from bringing code into Excel if I can avoid it.
    I personally would rather create 37 IF functions in a formula (which you can do, it's just tedious) than to create a UDF and save the workbook as .xlsm.

  11. #11
    Forum Contributor
    Join Date
    10-09-2018
    Location
    Quebec, Canada
    MS-Off Ver
    Office 365
    Posts
    129

    Re: Matrix or Pivot table or else?

    Yes I can create and use .xlsm workbooks.

    I just need to know what you mean by "UDF" ?

    Is it a VBA code?

  12. #12
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Matrix or Pivot table or else?

    UDF stands for User Defined Function. When you create a UDF, you are creating a custom function (through VBA code) to be used in that workbook.

    If you create a UDF named TEXTJOIN (some don't like to name UDF's the same as built in functions but we won't get into that), you can use the TEXTJOIN function the same way that those with Office 365 use it.

    You can use your favorite search engine to search for "TEXTJOIN UDF" and go from there.

  13. #13
    Forum Contributor
    Join Date
    10-09-2018
    Location
    Quebec, Canada
    MS-Off Ver
    Office 365
    Posts
    129

    Re: Matrix or Pivot table or else?

    Ok. I'll look it up this afternoon and will post any question I will surely have…

    Thank you!

  14. #14
    Forum Contributor
    Join Date
    10-09-2018
    Location
    Quebec, Canada
    MS-Off Ver
    Office 365
    Posts
    129

    Re: Matrix or Pivot table or else?

    So thanks to your suggestion and to the Textjoin function, I was able to create my table with the proper layout.

    Thank you so much Falcondude!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to convert text table to a matrix (like using pivot)
    By polipo in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 10-31-2022, 07:27 AM
  2. Possibly using pivot table to sort this matrix?
    By namy77 in forum Excel General
    Replies: 3
    Last Post: 12-05-2017, 01:54 PM
  3. Should I use a pivot table to create a matrix?
    By dazbear in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 03-13-2015, 02:47 PM
  4. Convert a Matrix into a List. Can I use Pivot Table for that?
    By klebergreco in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-22-2014, 08:28 AM
  5. Replies: 1
    Last Post: 05-16-2014, 07:34 PM
  6. Pivot Table Skills Matrix Trouble
    By ramjet in forum Excel General
    Replies: 0
    Last Post: 06-05-2012, 11:14 AM
  7. Pivot table as matrix
    By Shadmani in forum Excel General
    Replies: 0
    Last Post: 12-20-2010, 05:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1