adding up multiple HLOOKUP results

hello, ok, so i'm not making much headway on this one... i've learnt to do a HLOOKUP formula, but how can I add up the results when there's more than one (i may have up to 8 or 9 in total)?


i've also struggled with returning the correct column value - i can't work out how to return the cost column...

i've tried using SUMPRODUCT but that doesn't work.... is there a simpler overall formula i should be considering instead of HLOOKUP?


here's a screen shot - i only want to add the quantities and costs if "selection" appears in row 1.



cheers


Ric

MacBook Pro 15″, macOS 12.2

Posted on Apr 9, 2022 2:35 AM

Reply
Question marked as Top-ranking reply

Posted on Apr 10, 2022 3:30 AM

I did a poor job of recreating your table. As simple as it was I still made it wrong. The ranges that worked in my table failed in yours. For your original table it should have been:


A3 =SUMIFS(D3:J3,D$2:J$2,"Qty",$D$1:$J$1,"selection")

B3 =SUMIFS(E3:K3,E$2:K$2,"£",$D$1:$J$1,"selection")


Anyway, it is probably better to have the hidden row Barry suggested so you don't have to play tricks. I would suggest, though, that your hidden row contain the word "selection" in both cells (above "qty", too, not just above "£") so your formula can be the same in columns A and B (other than "qty" being replaced with the "£").

7 replies
Question marked as Top-ranking reply

Apr 10, 2022 3:30 AM in response to ric frankland

I did a poor job of recreating your table. As simple as it was I still made it wrong. The ranges that worked in my table failed in yours. For your original table it should have been:


A3 =SUMIFS(D3:J3,D$2:J$2,"Qty",$D$1:$J$1,"selection")

B3 =SUMIFS(E3:K3,E$2:K$2,"£",$D$1:$J$1,"selection")


Anyway, it is probably better to have the hidden row Barry suggested so you don't have to play tricks. I would suggest, though, that your hidden row contain the word "selection" in both cells (above "qty", too, not just above "£") so your formula can be the same in columns A and B (other than "qty" being replaced with the "£").

Apr 9, 2022 2:42 PM in response to ric frankland

While "merged cells" is a supported feature in Numbers, using it brings forth some disadvantages. Your experience appears to have uncovered one of them.


Here's an example built on Badunit's SUMIFS, and revised to fit your table layout.


The solution does NOT use merged cells, but does employ the standard behaviour of text in Numbers automatically flowing into an empty cell to its right if the string is too long to fit a cell in one row and the cell to the right is empty.


To fill the need for a "£" marker for money amounts to be included in the total in Column B. I've inserted a new header row (row 2) and a formula to place £ in cells one column to the right of columns showing "Selection" is row 1.


R0w 2 would be hidden in normal use.



The formula shown below the table is entered in cell A4, and can be filled down from there.

The formula in B4 is similar, and is shown below this copy of the table:

With row 2 hidden, and no cell selected. the table has this appearance.



Regards,

Barry

Apr 9, 2022 6:24 AM in response to Badunit

cool, much simpler, thanks Badunit, but because i've merged two columns for "selection" (i'd like to keep it this way if possible), is there a way for the formula to read the next column to the right please, as it now doesn't read the "£" column?


i've just tried using the COLUMN formula... but not sure how to get this to work... i keep getting errors....

Apr 10, 2022 1:25 AM in response to Badunit

thanks Badunit, but when i try that, the error message says "SUMIFS requires that all range arguments are the same size." - i guess because it sees the merged cell as a single cell....?


sorry if i'm doing this wrong but even copying/pasting the code you gave into my sheet still presents this problem.


i think what i'm going to do is use this same formula, but use Barry's idea (thanks Barry!) to create a hidden row that shows whatever is in Row 1, but has the same number of cells....




thanks again Badunit and Barry!


Ric

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

adding up multiple HLOOKUP results

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.