Get certain values from complex table - excel

I have a rather complicated data structure in Excel (Google Drive link). I would like to get certain values from this table:
I tried a combination of a row-column INDEX MATCH. However this did not work because I do not know how to locate the desired column.
Any suggestions how to transform this data structure?

Add two helper columns in M and N.
In M4 enter:
=MATCH(H4,A:A,0)
IN N4 enter:
=COUNTIF(A:A,H4)-1+M4
These will return the first and last row numbers for the Group.
Then in J4, array enter:
=INDEX(INDEX(INDEX($D:$D,$M4):INDEX($D:$D,$N4),MATCH(J$3,INDEX($D:$D,$M4):INDEX($D:$D,$N4),0)+1):INDEX($D:$D,$N4),MATCH(1,1/(INDEX(INDEX($B:$B,$M4):INDEX($B:$B,$N4),MATCH(J$3,INDEX($D:$D,$M4):INDEX($D:$D,$N4),0)+1):INDEX($B:$B,$N4)=$I4),0))
Remembering to confirm with Ctrl+Shift+Enter. Then fill across and down as needed.
There's probably a simpler version!

If you can add a helper column A you can do the following
A3: =E4, A4: =E4, A5: =E4, A6: =E4, A7: =E8...
Once you have the first four values you can drag it down for the frist group and then from group 2 drag those four formulas down to the end.
You data will look like this:
Then in Cell K4 you enter the following formula:
=SUMIFS($E$3:$E$26,
$A$3:$A$26, K$3,
$B$3:$B$26, $I4,
$C$3:$C$26, $J4)
Once you have this you can drag it down and right arbitrarily.
The only issue here is getting the Dates into the helper column, the approach above is only easy if all groups are of equal size but I assumed that given the sample data.

This solution does not required working (helper) cells, just a minor adjustment to your output table:
Enter the word Date in cell I3
Then enter this FormulaArray in cell J4 then copy till J7 then to range K4:L7
(Formulas Array are entered by pressing [Ctrl] + [Shift] + [Enter] simultaneously)
=INDEX($D$2:$D$26,
MATCH($H4&$I$3&J$3,$A$2:$A$26&$B$2:$B$26&$D$2:$D$26,0)
+MATCH($I4,OFFSET($B$2:$B$26,
+MATCH($H4&$I$3&J$3,$A$2:$A$26&$B$2:$B$26&$D$2:$D$26,0),0),0))

Related

How can I get Excel to generate columns dynamically, according to the values in a different column?

In Excel 2016, I have a "Brands" column, each of its rows containing a string. The set of possible string values is limited, and they may appear more than once.
There is related data in another column, "Models". Each model value is always different.
How can I get Excel to generate a column for each existing brand and populate it with the corresponding Models in an automatic way?
My problem is that I can't do it manually because for each analysis, the amount of Brands is different and I don't know it beforehand.
This would be the input:
And this is the expected output:
Any ideas?
Thank you in advance!
Try using an array formula. First, put the distinct brand values on row 1, starting in column D. You can use column C if you want, but I like to have an empty column between the data and the desired results.
D1 = Apple, E1 = Nokia, F1 = Samsung, G1 = Xiaomi
Then, just below Apple in cell D2, paste this formula:
=IFERROR(INDEX($B$2:$B$9999, SMALL(IF(D$1=$A$2:$A$9999, ROW($A$2:$A$9999)-ROW($A$2)+1), ROW(1:1))),"")
If you have more than 9999 rows, then adjust as needed in the formula.
With the cursor still in the formula, make it an array by simultaneously pressing CTRL-SHIFT-ENTER.
Copy the formula across to cells E2, F2 and G2. You may need to repeat the array trick (CTRL-SHIFT-ENTER) for each of those again if things look wrong. So, your excel will look like this:
Now, drag the formulas down as far as you need. The iferror part of the formula will ensure that cells look clean if no more models are found.
---EDIT AFTER RECENT COMMENT---
I cannot determine how to automatically pick distinct values from column A and automatically convert them to a row. It's easy to keep it in a column, but the transpose to row is troubling.
At any rate, here's the ugly update. Cell D1 would simply state "Brands". In cell D2, make this an array formula (CTRL-SHIFT-ENTER).
=IFERROR(INDEX($A$2:$A$9, MATCH(0, COUNTIF($D$1:D1, $A$2:$A$9), 0)), "")
So, row 2 will be your brands. Drag the formula across, repeat the array trick.
Now, in cell E1, type formula =D2. Drag across.
Place the formula suggestion from the original answer, starting in row 3. End result looks like this below. It should be "automated" now, but it's not appealing. Minor edits will help (making row 1 nearly invisible, for example).

Identify minimum and maximum values based on 3 criteria

In the table shown, I need a formula for column D that will indicate the first date (minimum) and most recent date (maximum) that each participant (in column A) took survey A (in column C). Column D would need to indicate "first" and "last" tied to the Participant ID--for example, I would want D2 to populate with "3Last" and D5 to populate with "3First." Column E displays what I would need column D to display. If it's not a first or last date (something in between), or if it's not survey A, the cell in column D would be left blank or 0. If there is only one date that meets the criteria, it should return "First" rather than "Last." I'm pretty stumped on this one... Any help is much appreciated!
In E2, insert the ARRAY formula listed below. If you have never used an array formula, follow these steps:
select the formula from this page
copy it
go to excel
select cell E2,
press the 'F2' key
paste the formula
press CTRL+SHIFT+Enter (instead of just pressing enter)
To copy down, follow these steps:
Copy cell E2
Move down to cell E3 (instead of selecting a range)
Paste in cell E3
Select your range and paste from there.
If you don't copy down in this manner, it will tell you that you cannot change the array...
=IF($C2="A",IF($B2=MIN(IF(($C$2:$C$7=$C2)*($A$2:$A$7=$A2),$B$2:$B$7)),CONCATENATE($A2,"Last"),IF($B2=MAX(IF(($C$2:$C$7=$C2)*($A$2:$A$7=$A2),$B$2:$B$7)),CONCATENATE($A2,"First"))),0)
HTH

I need to find an excel formula that I can use to create a unique list of Item numbers from an array

I need to find an excel formula that I can use to create a unique list of Item numbers from an array. I do not want to count them I just want to make a list of the Item Numbers. These part numbers are actually Alpha Numeric and can have repeating numbers through out the array multiple times. There is one other catch this list will have empty cells in it and could also be the first record in the array. This data is being pulled into Excel through a Jet report add-in for Excel.
Example: Starting in cell A1..A9
Item No.
<BLANK>
7810042050
783979
7810006045
7810006042
7810006032
<BLANK>
7810006022
7810006032
With values in column A, in C1 enter:
=MAX(A1:A10)
in C2 enter the array formula:
=MAX(IF(A$1:A$10<C1,A$1:A$10,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
EDIT#1:
Chris Neilsen has pointed out that the values in column A are actually Text rather than Numeric. To accommodate this, two changes must be made to the formulas:
A1 must be excluded
the alphas must be converted to numeric.
So we will replace the normal formula:
=MAX(A1:A10)
with the array formula:
=MAX(--(A2:A10))
and replace:
=MAX(IF(A$1:A$10<C1,A$1:A$10,""))
with the array formula:
=MAX(IF(--(A$2:A$10)<C1,--(A$2:A$10),""))
and then copy down.
If you have alpha characters in the part numbers you can do this in 2 steps.
Both are array formulas and you need to use Ctrl-Shift-Enter
Col B - sorted list of items in Col A
B2 =IFERROR(INDEX($A$2:$A$10,MATCH(COUNTA($A$2:A2),COUNTIF($A$2:$A$10,"<="&$A$2:$A$10),0),1),"")
Col C - eliminate the duplicates
C2 = IFERROR(INDEX($B$2:$B$10, MATCH(0, COUNTIF($C$1:C1, $B$2:$B$10), 0)),"")
Copy both formulas down.
I tried to combine the two formulas but nesting an array (results in Col B) with varying row ranges did not work out. I could not find a way but the two formulas together will work.
Enter this Formula Array in B2 and copy to B3:B10
FormulaArrays are entered pressing [Ctrl] + [Shift] + [Enter] simultaneously, you shall see { and } around the formula if entered correctly
=IFERROR(
INDEX($A$2:$A$10,
MATCH(1,1+COUNTIF($B1:$B$1,$A$2:$A$10)+(($A$2:$A$10="")*1),0)*1),"")

How to drag/copy Excel formulae to include cells at specified intervals

I have an Excel sheet in which I want start column D with the following formula:
=AVERAGE(C7:C10)
I want to be able to drag down column D to give the following formulae:
=AVERAGE(C11:C14)
=AVERAGE(C15:C18)
=AVERAGE(C19:C22)
etc.
However, if I just naively drag down, instead, I get:
=AVERAGE(C8:C11)
=AVERAGE(C9:C12)
=AVERAGE(C10:C13)
How can I change this behavior?
In column D enter
=AVERAGE(OFFSET($C$1,4*ROW(C1)+2,0,4))
Then when you drag it down column D, each successive cell will have the reference incremented by 4.
This answer assumes that the size of the ranges remain constant. If, for example, column G is unpopulated then G1=7;G2=11. Select both cells and pull the fill handle down as far as needed. The formula for D1 is=AVERAGE(INDIRECT("C"&G1&":C"&G1+3)), which can be filled down as far as needed.

Excel copy rows & colums but skip blanks

How can I copy the contents of this 'table' using a formula (not VBA or manual copy/paste) into a single column with no blanks?
EDIT
The content of the table will be changing so we want something dynamic
So the output would be something like:
Home
About Us
Financial Planning
Accounting Services
Contact Us
Our Company
Superannuation
Personal
Our Lcoation
...
... etc
It's possible to get the result with a single and long array formula, however, I'd prefer a helper column.
Data region: A1:E5
A6, copied down: array formula
={SMALL((IF($A$1:$E$5="";"";ROW($A$1:$E$5)*1000+COLUMN($A$1:$E$5)));ROW()-ROW($A$6)+1)}
The formula is inserted with Ctrl-Shift-Enter from formula window. Curled brackets are inserted by Excel, not by a user.
Row number of a non-blank cell is multiplied by 1000, and column number is added to it, giving a unique number. The solution works if there are no more than 999 columns. The numbers are listed in the growing order.
B6, copied down:
=OFFSET($A$1;INT($A6/1000)-1;$A6-INT($A6/1000)*1000-1)
The number in the helper row is transformed into row and column offset.
Example - Matrix_transposed_to_one_column.xls
Have you tried (down the column you want the data in):
=A1
=A2
=A3
=A4
=A5
=B2
=B3
=B4
=C2
..etc

Resources