+ Reply to Thread
Results 1 to 11 of 11

How to get an array formula to work both vertically and horizontally?

  1. #1
    Registered User
    Join Date
    11-16-2014
    Location
    Mt Isa
    MS-Off Ver
    2007
    Posts
    40

    How to get an array formula to work both vertically and horizontally?

    Hi Team Excel

    I am at a loss as to why this array formula works for my horizontal values but wont work vertically. I am sure there is a simple reason, but i am still learning all this and i dont know what it is, please help.

    Attached is a very simple table. It contains letter grades, which are then reference a number value from another table (_Reports) to give it a numerical value, so that it can then be averaged, before changing it back into a Letter grade again. This works if i place the array formula in the horizontal average cell, but wont work if i try an average down a column.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    20,914

    Re: How to get an array formula to work both vertically and horizontally?

    Try this array formula instead:

    =INDEX(_Reports[Grade],MATCH(ROUNDDOWN(AVERAGE(IF(TRANSPOSE(D4:D7)=_Reports[Grade],_Reports[Score])),0),_Reports[Score],0))
    Glenn



  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    27,600

    Re: How to get an array formula to work both vertically and horizontally?

    For the columns, you need to transpose the lookup arrays:

    =INDEX(_Reports[Grade],MATCH(ROUNDDOWN(AVERAGE(IF(D4:D7=TRANSPOSE(_Reports[Grade]),TRANSPOSE(_Reports[Score]))),0),TRANSPOSE(_Reports[Score]),0))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    STOP PRESS: Forum Rules Updated September 2018! Please read them here.
    Are you new to Power Query and don't know what to do with the code you've been given? Have a look here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  4. #4
    Registered User
    Join Date
    11-16-2014
    Location
    Mt Isa
    MS-Off Ver
    2007
    Posts
    40

    Re: How to get an array formula to work both vertically and horizontally?

    Thank you, that worked a treat. Can you please explain what is happening here, so i can increase my understanding of excel. Cheers.

    No dramas if you cant/dont want too

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    27,600

    Re: How to get an array formula to work both vertically and horizontally?

    Which one of us are you addressing? You have been offered two solutions.

    Use the Evaluate Formula option on the Formulas ribbon to step through it so you can see what is happening. Essentially in mine, because you were working with rows in the main table and columns in the lookup table, you need to switch this when you want to work with columns in the main table. TRANSPOSE simply turns the lookup arrays 90 degrees to facilitate this.
    Last edited by AliGW; 07-14-2019 at 02:33 AM.

  6. #6
    Registered User
    Join Date
    11-16-2014
    Location
    Mt Isa
    MS-Off Ver
    2007
    Posts
    40

    Re: How to get an array formula to work both vertically and horizontally?

    Hi Ali,

    Either, what does Transposing do? Why is it needed for vertical rather than horizontal?

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    27,600

    Re: How to get an array formula to work both vertically and horizontally?

    I've answered your question above.

    Glenn's approach is the same, but he's chosen to transpose the main table column instead. Essentially, one or other of the arrays needs transposing.
    Last edited by AliGW; 07-14-2019 at 02:39 AM.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    27,600

    Re: How to get an array formula to work both vertically and horizontally?

    Does this answer your question?

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    20,914

    Re: How to get an array formula to work both vertically and horizontally?

    In your original (working) formula, the construction of the formula meant that you were multiplying two arrays. One (sheet 1) was a horizontal array, and the other (Codes) was a vertical array. When multiplied together they produced a 4 x 15 array of TRUE/FALSE responses.

    In your original (non-working) formula, the two arrays were vertical. When multiplied together The first four rows of the codes array were searched for the 4 values in sheet 1. the remaining 11 rows of codes produced an error and the formual fell over. To get it to work, you had to coerce Excel to make one of the arrays horizonatal. That's what TRANSPOSE does.

  10. #10
    Registered User
    Join Date
    11-16-2014
    Location
    Mt Isa
    MS-Off Ver
    2007
    Posts
    40

    Re: How to get an array formula to work both vertically and horizontally?

    Thank you both, youre awesome. I figured it was something like this, but it is always good to ask and seek clarification from those in the know.

    Thank you for your help and support again.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    27,600

    Re: How to get an array formula to work both vertically and horizontally?

    Glad to have helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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