Matching multiple criteria (matrix transpose) - excel

In Excel, I want to lookup/index a table that matches both the station_number and the month.
Say I have the following data on sheet1:
Jan Feb Mar Apr May
station1 1 8 17 14 0
station5 4 5 8 10 14
station7 18 7 4 9 10
station10 5 11 15 12 4
On sheet2, I want to fill in the details below:
Station1 Station2 Station3 Station4 Station5 Station6
Jan 1 4
Feb 8 5
Mar 17 8
Apr 14 10
May 0 14
What is the formula I use in order to look up sheet1 and complete sheet2? I tried =VLOOKUP(B1&A2,'Sheet1'!A1:F5,2,FALSE) which is obviously incorrect. Any help would be great.

You should use Hlookup something like following for column station1:
=+HLOOKUP(A2,Sheet1!$A$1:$F$2,2,0)
It should work and hope this helps also.
where sheet1 is the actual source of your input data, but offcourse with every column the references must be change so for station10 column formula would be:
=+HLOOKUP(A2,Sheet1!$A$1:$F$5,5,0)

Please try:
=IFERROR(INDEX(sheet1!$B$2:$F$5,MATCH(J$1,sheet1!$A$2:$A$5,0),MATCH($I2,sheet1!$B$1:$F$1,0)),"")
in sheet2 where your 1 is (assumed to be J2), and copy across and down to suit.

Related

Convert matrix table into single row in Excel (no VBA)

In Excel, my Data looks like this
A B C D
15 16 17 18
11 12 13 14
7 8 9 10
I am looking for a solution (without VBA) to transform my data into a single row, like this:
15 16 17 18 11 12 13 14 7 8 9 10
For those who have access to the TOROW function:
=TOROW(A1:D3)
Use this function:
=OFFSET(Matrix,MOD((COLUMN()-COLUMN($A$7)),ROWS(Matrix)),TRUNC((COLUMN()-COLUMN($A$7))/(ROWS(Matrix))),1,1)
If you have TEXTJOIN() then try-
=TRANSPOSE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>",TRUE,A1:D3)&"</s></t>","//s"))

Excel: Dynamic Range Date used in other fields: Sumproduct

I am using sumproduct formula to get the first four month, then the second four month, third four month of net sales until one month before today. This is my formula that I used:
=IFERROR(SUMPRODUCT($B3:$Y3*(COLUMN($B3:$Y3)>=AGGREGATE(15,6,COLUMN($B3:$Y3)/($B3:$Y3<>0),1)+4*(COLUMNS(B3)-1))*(COLUMN($B3:$Y3)<AGGREGATE(15,6,COLUMN($B3:$Y3)/($B3:$Y3<>0),1)+4*(COLUMNS(B3)))*($B$1:$Y$1<EOMONTH(TODAY(),-1)+1)),0)
However, I need to capture the same range as I have it for the net sales as for other measures like COGS in my example. I cannot use the formula above for the other measures like COGS as sometimes they are zero in the same range as in the Net Sales.But I need to capture the zeros here as well.
Example 1
Example 2
Net Sales
Jan
Feb
Mar
Apr
May
June
July
Aug
Sept
Oct
Nov
Dec
0
0
2
3
4
5
2
3
2
3
2
4
---> 1st period= 14 2nd period= 10
COGS (follows the same date range as Net Sales)
Jan
Feb
Mar
Apr
May
June
July
Aug
Sept
Oct
Nov
Dec
0
0
0
0
0
2
1
4
2
3
2
4
---> 1st period= 2 2nd Period= 11
You can leave the entire range check logic from the first formula and change just the value range, i.e first formula in my sample:
=IFERROR(SUMPRODUCT($A3:$L3*(COLUMN($A3:$L3)>=AGGREGATE(15,6,COLUMN($A3:$L3)/($A3:$L3<>0),1)+4*(COLUMN(A3)-1))*(COLUMN($A3:$L3)<AGGREGATE(15,6,COLUMN($A3:$L3)/($A3:$L3<>0),1)+4*(COLUMN(A3)))*($A$2:$L$2<EOMONTH(TODAY(),-1)+1)),0)
second formula for COGS:
=IFERROR(SUMPRODUCT($O3:$Z3*(COLUMN($A3:$L3)>=AGGREGATE(15,6,COLUMN($A3:$L3)/($A3:$L3<>0),1)+4*(COLUMN(A3)-1))*(COLUMN($A3:$L3)<AGGREGATE(15,6,COLUMN($A3:$L3)/($A3:$L3<>0),1)+4*(COLUMN(A3)))*($A$2:$L$2<EOMONTH(TODAY(),-1)+1)),0)

How do I get each column of the same row in one line?

I have this columns in excel:
A B C D E F
Nima1 1 2 3 4 5
Nima2 6 7 8 9 10
Nima3 11 12 13 14 15
Nima4 16 17 18 19 20
and I want to show them like this:
Nima1 1
Nima1 2
Nima1 3
Nima1 4
Nima1 5
Nima2 6
…
Nima4 20
and so far I come up with nothing, every formula that I write doesn't work.
please if anyone knows how to do it, guide me through it.
In any unused cell to the right put in this formula,
'for system that use a comma as a list separator
=INDEX(A:E,(ROW(1:1)-1)/5+1,IF(COLUMN(A:A)=1,1,MOD(ROW(1:1)-1,5)+1))
'for system that use a semi-colon as a list separator
=INDEX(A:E;(ROW(1:1)-1)/5+1;IF(COLUMN(A:A)=1;1;MOD(ROW(1:1)-1;5)+1))
Fill right one column then fill both down until you get zeroes.

Merge columns from different sheets into specific order

I have an Excel file with three sheets of annual data. For example:
Sheet 1 is for year 2006
Site1 Site2 Site4
Jan 10 12 14
Feb 0 15 9
Sheet 2 is for year 2007
Site1 Site3 Site4
Jan 14 10 18
Feb 4 16 2
Sheet 3 is for year 2008
Site2 Site3 Site4 Site5
Jan 12 13 7 12
Feb 5 13 5 16
In Sheet 4, I want to combine these data under the specific Site_number (if the Site_number is unique, I want to add a column for that data). For example:
Sheet 4 should look like this:
Site1 Site2 Site3 Site4 Site5
2006 Jan 10 12 14
Feb 0 15 9
2007 Jan 14 10 18
Feb 4 16 2
2008 Jan 12 13 7 12
Feb 5 13 5 16
What would be a good way to go about this?
There are very many way of achieving your objective and with the columns apparently already sorted I would be tempted merely to add blank columns until each sheet has each Site in the same column. However instead with a lookup function something like:
=IFERROR(INDEX($C$10:$F$12,ROW(),IFERROR(MATCH(C$1,$C$10:$F$10,0),"")),"")
copied across and down to suit should work, provided Row1 has a complete list of unique Sites and, for the purposes of illustration, your original data is in the same sheet but moved down to start at Row10 and across one column (the latter to allow for manual addition of the year).
I'd suggest one sheet at a time and then merely copy and add/append into a new sheet as required.

Sum number according to date and name in excel

To sum the third column (numbers o companies) I've used this
=SUM(1/COUNTIF(Names;Names))
Names is name of array in C column and CTRL+SHIFT+ENTER and it works perfectly.
Now I'd like to sum earnings but only for each company once and with the latest data. For example, the result shoud be like this
=C4+C6+C7+C8+C9+C10
(93)
Thanks
A B C D
1 # company earnings date
2 1 ISB 12 10/11/2011
3 2 DTN 15 11/11/2011
4 3 ABC 13 12/11/2011
5 4 ISB 17 13/11/2011
6 5 RTV 18 14/11/2011
7 6 DTN 22 15/11/2011
8 7 PVS 11 16/11/2011
9 8 ISB 19 17/11/2011
10 9 ANH 10 18/11/2011
Sum 6 93
Assuming ascending dates, you could try with CTRL+SHIFT+ENTER in C11:
=SUM((MAX(A2:A10)-MATCH(B2:B10,LOOKUP(MAX(A2:A10)-A2:A10,A2:A10-1,B2:B10),0)=A2:A10-1)*C2:C10)
I'd suggest using a helper column as the easiest approach. In E2 use this formula
=IF(COUNTIF(B2:B$1000,B2)=1,C2,"")
and copy down the column. Now sum column D for the required answer.
Note that the above formula assumes 1000 rows of data maximum, increase if required.

Resources