+ Reply to Thread
Results 1 to 28 of 28

Need help with INDEX formula

  1. #1
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Need help with INDEX formula

    Hi,


    I need help to integrate the INDEX formula in this LET function correctly.

    I want the Index to return values based upon references of my columns, not based upon which number the row/column has.
    This means that I can add/remove as many columns as I want and the formula will still look in the correct column.

    Now, for example, If I remove the column 'O', the formula changes and is not displaying what it should because the columns are hard coded in the very end of the formula.

    Attached spreadsheet.



    Regards
    Attached Files Attached Files
    Last edited by Tirrazo; 02-02-2023 at 01:37 PM. Reason: Added spreadsheet

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Need help with INDEX formula

    Just remove confidential infromation first.

    Without having a sheet to play with, many helpers will just look at this and move on... Just as I am.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Glenn Kennedy View Post
    Just remove confidential infromation first.

    Without having a sheet to play with, many helpers will just look at this and move on... Just as I am.
    Added the spreadsheet now

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Need help with INDEX formula

    But you haven't said HOW you want to identify the columns. At a guess:

    =LET(A,"AQRT",f,FILTER(A1:W33,(R1:R33>=Q35)*(R1:R33<=Q36)),IF(ISERR(ROWS(f)),"Ingen utbytte",SORT(INDEX(f,SEQUENCE(ROWS(f)),TRANSPOSE(LOOKUP(CODE(+MID(A,SEQUENCE(LEN(A)),1))-64,SEQUENCE(26)))),4)))
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,823

    Re: Need help with INDEX formula

    How about this?
    =SORT(CHOOSECOLS(FILTER(A1:T33,(O1:O33>=N35)*(O1:O33<=N36)),COLUMN(A1),COLUMN(N1),COLUMN(O1),COLUMN(Q1)),4,1)

  6. #6
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Gregb11 View Post
    How about this?
    =SORT(CHOOSECOLS(FILTER(A1:T33,(O1:O33>=N35)*(O1:O33<=N36)),COLUMN(A1),COLUMN(N1),COLUMN(O1),COLUMN(Q1)),4,1)
    Thank you! This formula gave me an error. Could you try to implement it in the sheet so I can download it?

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Need help with INDEX formula

    Did you look at Post 4?

  8. #8
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Glenn Kennedy View Post
    But you haven't said HOW you want to identify the columns. At a guess:

    =LET(A,"AQRT",f,FILTER(A1:W33,(R1:R33>=Q35)*(R1:R33<=Q36)),IF(ISERR(ROWS(f)),"Ingen utbytte",SORT(INDEX(f,SEQUENCE(ROWS(f)),TRANSPOSE(LOOKUP(CODE(+MID(A,SEQUENCE(LEN(A)),1))-64,SEQUENCE(26)))),4)))
    Thank you!
    If I remove columns, the formula changes. So this is still not working.

    In this example, I want to return the values of col A (1), col Q (17), col R (18), col T (20).
    The way I have been identifying them now is by column numbers, I can see that will not work if I remove or add columns.
    Can you make an example of how to return those 4 columns by identification, for example naming the columns?

  9. #9
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Glenn Kennedy View Post
    Did you look at Post 4?
    I am sorry. You didn't insert the code in the spreadsheet, just pasted it here?
    If so, I have to test again

    I tested now and the solution in post 4 is not working.
    You can see the two columns in the arraw only shows "0" after I added more columns.
    Attached Images Attached Images
    Last edited by Tirrazo; 02-03-2023 at 02:59 AM.

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Need help with INDEX formula

    Did you actually open the file???? Did you look at the formula I used??

    I have put same the formula (again) into the file. This time BESIDE your formula (yours shaded green... mine is blue).

    =LET(A,"AQRT",f,FILTER(A1:W33,(R1:R33>=Q35)*(R1:R33<=Q36)),IF(ISERR(ROWS(f)),"Ingen utbytte",SORT(INDEX(f,SEQUENCE(ROWS(f)),TRANSPOSE(LOOKUP(CODE(+MID(A,SEQUENCE(LEN(A)),1))-64,SEQUENCE(26)))),4))))

    The bit in RED in the formula (above) defines the columns to be returned.
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,823

    Re: Need help with INDEX formula

    Sorry about that. I pasted the formula in AFTER i tested it by deleting the columns- oops. This one should work - you can delete columns and it will still show the right info:

    =SORT(CHOOSECOLS(FILTER(A1:W33,(R1:R33>=Q35)*(R1:R33<=Q36)),COLUMN(A1),COLUMN(Q1),COLUMN(R1),COLUMN(T1)),4,1)

    In the attached, my results are BELOW your results
    Attached Files Attached Files
    Last edited by Gregb11; 02-03-2023 at 07:04 AM.

  12. #12
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Glenn Kennedy View Post
    Did you actually open the file???? Did you look at the formula I used??

    I have put same the formula (again) into the file. This time BESIDE your formula (yours shaded green... mine is blue).

    =LET(A,"AQRT",f,FILTER(A1:W33,(R1:R33>=Q35)*(R1:R33<=Q36)),IF(ISERR(ROWS(f)),"Ingen utbytte",SORT(INDEX(f,SEQUENCE(ROWS(f)),TRANSPOSE(LOOKUP(CODE(+MID(A,SEQUENCE(LEN(A)),1))-64,SEQUENCE(26)))),4))))

    The bit in RED in the formula (above) defines the columns to be returned.

    Thank you!

    As you can see I have opened the spreadsheet and I can see your code, but it is not working.
    Clearly, you can see that after removing column L ( empty column)both of the formulas are not returning the correct columns in the array anymore.
    Attached Images Attached Images

  13. #13
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Gregb11 View Post
    Sorry about that. I pasted the formula in AFTER i tested it by deleting the columns- oops. This one should work - you can delete columns and it will still show the right info:

    =SORT(CHOOSECOLS(FILTER(A1:W33,(R1:R33>=Q35)*(R1:R33<=Q36)),COLUMN(A1),COLUMN(Q1),COLUMN(R1),COLUMN(T1)),4,1)

    In the attached, my results are BELOW your results
    Thank you!
    I have tested this spreadsheet and I can both remove column L and add another one without the numbers failing like my own solution.
    Have to test this setup against my main sheet, but comfortable this could be a good solution!

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Need help with INDEX formula

    You need to specify which columns you want to return in the firdt red bit in the formula i gave you. If it is ALWAYS those 4 columns, use Greg's approach.

  15. #15
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Glenn Kennedy View Post
    You need to specify which columns you want to return in the firdt red bit in the formula i gave you. If it is ALWAYS those 4 columns, use Greg's approach.
    That is the problem. I am going to use it in many different places which will be affected of the columns around.
    The first part, you have AQRT marked red. How do I specify the columns actually?

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Need help with INDEX formula

    Just enter the column letters as shown. Type in "BCDE" if you want those columns returned.

    If your columns had headers, it would be essier... but they don't.

    I think you haven't specified what yiu want, clearly enough.

  17. #17
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Glenn Kennedy View Post
    Just enter the column letters as shown. Type in "BCDE" if you want those columns returned.

    If your columns had headers, it would be essier... but they don't.

    I think you haven't specified what yiu want, clearly enough.
    Let me take a look again, guess I didn't quite understand how you did it until now.
    I will have 11 more of this setup to the right. This is only data for january, I will have data for a whole year. So there will be many columns to the right where each month (like this) result in an array below with 4 columns I want information from.
    The first column will alway be 1, but the 3 next in every formula will have the same distance as this setup with columns is for 12 different months with data, but the type of data is always found in the same distance from each other.

    The problem I got and that's why I requested help here is because I have to add more columns with more data for each month. As I start to do that, all of the 12 formulas stop working and that gives me a load of work.

  18. #18
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,823

    Re: Need help with INDEX formula

    So is the formula in Post #11 working for you or do you need it to do something else?

  19. #19
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Gregb11 View Post
    So is the formula in Post #11 working for you or do you need it to do something else?
    It is working in this spreadsheet which was a test. Give me a little time to test it out and see how it goes.

  20. #20
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Gregb11 View Post
    Sorry about that. I pasted the formula in AFTER i tested it by deleting the columns- oops. This one should work - you can delete columns and it will still show the right info:

    =SORT(CHOOSECOLS(FILTER(A1:W33,(R1:R33>=Q35)*(R1:R33<=Q36)),COLUMN(A1),COLUMN(Q1),COLUMN(R1),COLUMN(T1)),4,1)

    In the attached, my results are BELOW your results
    I am looking into this spreadsheet now and need to to ask how you define those 4 columns to be returned?

  21. #21
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,823

    Re: Need help with INDEX formula

    Not sure I understand, but the Columns returned are defined by this part:
    COLUMN(A1),COLUMN(Q1),COLUMN(R1),COLUMN(T1)

    This allows for if you delete or insert columns, the reference will also change appropriately.

  22. #22
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Gregb11 View Post
    Not sure I understand, but the Columns returned are defined by this part:
    COLUMN(A1),COLUMN(Q1),COLUMN(R1),COLUMN(T1)

    This allows for if you delete or insert columns, the reference will also change appropriately.

    Hi again,

    I am looking into this in the weekend, haven't had time to test it out.

    Would it also be possible to name the 4 columns I am returning with references?
    At the top I wrote 4 references marked as yellow. Instead of the formula looking in column A2, Q2, R2, T2, it will look for the references I made as they are stuck with the column:
    "Tall", "Nummer", "Dato1", "Dato2"

    So
    A2=Tall
    Q2=Nummer
    R2=Dato1
    T2=Dato2


    Edit:
    I also had to move the whole area, the columns and data to the right and a little down to get some space around. After that, I was not able to get the formula to work again.
    If I have to edit this, what part of the formula do I need to change?
    Attached Files Attached Files
    Last edited by Tirrazo; 02-17-2023 at 12:47 PM.

  23. #23
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,823

    Re: Need help with INDEX formula

    The reason it didn't work is because you need to keep the range starting with A. So you can do this and it works:

    =SORT(CHOOSECOLS(FILTER($A2:AA24,(V2:V24>=U26)*(V2:V24<=U27)),COLUMN(E2),COLUMN(U2),COLUMN(V2),COLUMN(X2)),4,)

  24. #24
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Gregb11 View Post
    The reason it didn't work is because you need to keep the range starting with A. So you can do this and it works:

    =SORT(CHOOSECOLS(FILTER($A2:AA24,(V2:V24>=U26)*(V2:V24<=U27)),COLUMN(E2),COLUMN(U2),COLUMN(V2),COLUMN(X2)),4,)
    Thank you, I made it work again

    What about the column references, is that possible?

  25. #25
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,823

    Re: Need help with INDEX formula

    What about the column references, is that possible?
    I'm not sure exactly what you mean. Why do you want to do that if this already works? Are you saying you'd want it to search the top row and whenever if finds that text to use that column?

  26. #26
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Gregb11 View Post
    I'm not sure exactly what you mean. Why do you want to do that if this already works? Are you saying you'd want it to search the top row and whenever if finds that text to use that column?
    Yes, exactly. That is for me to have better control because there will be a lot of columns in my final spreadsheet.

  27. #27
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,823

    Re: Need help with INDEX formula

    Replace the "Column(E2)" in the formula with "MATCH("Tall",A1:W1,0), etc. The A1:W1 is whatever range you're working with.



    =SORT(CHOOSECOLS(FILTER(A2:W34,(R2:R34>=Q36)*(R2:R34<=Q37)),MATCH("Tall",A1:W1,0),MATCH("Nummer",A1:W1,0),MATCH("Dato1",A1:W1,0),MATCH("Dato2",A1:W1,0)),4,1)
    Attached Files Attached Files

  28. #28
    Forum Contributor
    Join Date
    07-01-2019
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Need help with INDEX formula

    Quote Originally Posted by Gregb11 View Post
    Replace the "Column(E2)" in the formula with "MATCH("Tall",A1:W1,0), etc. The A1:W1 is whatever range you're working with.



    =SORT(CHOOSECOLS(FILTER(A2:W34,(R2:R34>=Q36)*(R2:R34<=Q37)),MATCH("Tall",A1:W1,0),MATCH("Nummer",A1:W1,0),MATCH("Dato1",A1:W1,0),MATCH("Dato2",A1:W1,0)),4,1)
    Thank you very much, will test this out!

+ 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. [SOLVED] Index Match not cycling through entire index. Formula not updating when values change...
    By nordxnortheast in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-07-2020, 10:44 AM
  2. [SOLVED] Index/Aggregate formula calculates correct row but does not yield name from Index array
    By FivestarMac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-17-2019, 05:07 PM
  3. Replies: 1
    Last Post: 08-17-2019, 01:11 PM
  4. Index Match formula changing my Index daily
    By vitt4300 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-31-2017, 02:19 PM
  5. [SOLVED] This formula works but I donīt understand why Index(Index) match
    By campelliann in forum Excel General
    Replies: 2
    Last Post: 01-25-2016, 05:55 PM
  6. Index Match Formula, can index be fixed?
    By herschen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-02-2015, 08:28 PM
  7. Index Match Index Formula work slow
    By avk in forum Excel General
    Replies: 9
    Last Post: 03-07-2012, 02:19 PM

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