I need some advice for the following task, I have an Excel sheet with 2 columns RESPONSIBLE and SERVICE (see Sheet1 of Attached file )
I need to create on another Excel sheet the matrix as Sheet2 in attached file.
Use the following array formula in B2 and drag/copy as required:
=IF(AND($A2<>"",B$1<>"")=TRUE,IF(ISNUMBER(MATCH($A2&B$1,Sheet1!$A:$A&Sheet1!$B:$B,0))=TRUE,"x",""),"")
To populate the column headers use the following array formula in B1 and drag/copy:
=IFERROR(INDEX(Sheet1!$B$2:$B$100,MATCH(0,COUNTIF($A$1:A1,Sheet1!$B$2:$B$100),0)),"")
To populate the row headers use the following array formula in A2 and drag/copy:
=IFERROR(INDEX(Sheet1!$A$2:$A$100,MATCH(0,COUNTIF($A$1:A1,Sheet1!$A$2:$A$100),0)),"")
Enter all the above formulas with ctrl + shift + enter
I tested the above formulas by increasing the data and it slowed down my excel file. The reason is most likely the first formula.
If you add a helper column in sheet1 then you can add this in C2 (not an array formula):
=A2&B2
Then in sheet2, B2 you can use (not an array formula):
=IF(ISNUMBER(MATCH($A2&B$1,Sheet1!$C:$C,0))=TRUE,"x","")
This will substantially increase the speed to normal levels as the number of array formulas in the sheet are materially reduced.
Or
You can simply use a pivot table. Enter "Service" as column label and value, and "Responsible" as row label. The value should show count of service. The only difference will be that instead of "x" it will show a 1. You will also have to refresh the pivot table whenever you update the data.
Related
I have 3 columns in my excel sheet - ID, Version, Material No.
for ex -
and i want the pivot table to be like -
How can i create the third calculated column because it involves two aggregation function to create it.
I am looking for count of maximum version so i need MAX function also, not count of unique values.
Consider a solution based on worksheet functions.
Assuming the table is in B5:D14,
enter an array formula, which counts unique IDs
=SUM(N($B$5:$B$14<>$B$4:$B$13))
into G2, enter
COUNT($B$5:$B$14)-G2
in H2.
Enter an array formula (
type Ctrl+Shift+Enter
instead of just Enter),
which collects unique IDs on top and fill the rest of the output lines with blanks:
=IFERROR(INDEX($B$1:$B$14,SMALL(N($B$5:$B$14<>$B$4:$B$13)*ROW($B$5:$B$14),ROW(B5)-ROW($B$4)+$H$2))*N(SMALL(N($B$5:$B$14<>$B$4:$B$13)*ROW($B$5:$B$14),ROW(B5)-ROW($B$4)+$H$2)>0),"")
in G5, another array formula
=IF(LEN(G5)>0,MAX(N($B$5:$B$14=G5)*$C$5:$C$14),"")
in H5 and one more array formula
=IF(LEN(G5)>0,SUM(($B$5:$B$14=G5)*($C$5:$C$14=H5)),"")
in I5, select range G5:I5 and drag/copy it down.
I have an Excel with rows and columns as below:
I need to build a series like below in Excel with two columns as shown:
I have a huge data set where rows are dates and columns are data in half hours.
Which would be the best method?
I would suggest using the INDIRECT function thus:
In the column when you want to have the Row labels, put this formula:
=INDIRECT("R" & MOD(ROW()-1, COUNTA(A:A))+2 & "C1",FALSE)
Here A:A refers to the column where your row labels are stored and +2 is offset to the first row with a label.
In the column where you want the Column labels, put:
=INDIRECT("R1C" & ROUNDDOWN((ROW()-1)/COUNTA($B$1:$D$1),0)+2,FALSE)
Here $B$1:$D$1 refers to the range with your column labels, and +2 is again offset to the first column label.
Assuming your data is in the range C7:F12
We’ll need three fields to show the resulting series: Row, Col and Data
Row: in cell H7 enter this formula and copy till the last record:
=IF(EXACT(H6,H$6),1,
IF(EXACT($I7,CHAR(133)),"",
IF($I7=1,SUM(1,H6),H6)))
Col: in cell I7 enter this formula and copy till the last record:
=IF(EXACT(I6,I$6),1,
IF(EXACT(I6,CHAR(133)),CHAR(133),
IF(I6=COLUMNS($C$7:$F$12),
IF(H6=ROWS($C$7:$F$12),CHAR(133),1),
SUM(1,I6))))
Data: in cell J7 enter this formula and copy till the last record:
=IF(EXACT($I7,CHAR(133)),"",
INDEX($C$7:$F$12,$H7,$I7))
The following will produce your results but the array formula will impact calculation lag depending upon the number of rows and column of data in the original data matrix.
The array formula¹ in A10 is,
=IFERROR(INDEX(A$2:A$6, MATCH(0, IF(COUNTIF(A$9:A9, A$2:A$6&"")<COUNT($1:$1), 0, 1), 0)), "")
The standard formula in B10 is,
=IF(LEN(A10), INDEX($B$1:INDEX($1:$1, MATCH(1E+99,$1:$1 )), , COUNTIF(A$10:A10, A10)), "")
Data retrieval in C10 is accomplished with,
=INDEX(A:J,MATCH(A10,A:A,0),MATCH(B10,$1:$1,0))
Fill down as necessary.
¹ Array formulas need to be finalized with Ctrl+Shift+Enter↵. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. Try and reduce full-column references to ranges more closely representing the extents of your actual data. Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. See Guidelines and examples of array formulas for more information.
Posting a revised answer following sample data provided by user (left prior answer as it might be useful to other users)
Assuming your data is in the range C6:K11
We’ll need four fields to show the resulting series: Row, Col, 'DateandTime`
Row: in cell M7 enter this formula and copy till the last record:
=IF(EXACT(M6,M$6),1,
IF(EXACT($N7,CHAR(133)),"",
IF($N7=1,SUM(1,M6),M6)))
Col: in cell N7 enter this formula and copy till the last record:
=IF(EXACT(N6,N$6),1,
IF(EXACT(N6,CHAR(133)),CHAR(133),
IF(N6=COLUMNS($C$6:$K$6),
IF(M6=ROWS($B$7:$B$11),CHAR(133),1),
SUM(1,N6))))
Date: in cell O7 enter this formula and copy till the last record:
=IF(EXACT($N7,CHAR(133)),"",
INDEX($B$7:$B$11,$M7,0))
Time: in cell P7 enter this formula and copy till the last record:
=IF(EXACT($N7,CHAR(133)),"",
INDEX($C$6:$K$6,0,$N7))
Fields Row and Col can be hidden
I want to extract the last status of a item by date from the sample data given below:
http://i.stack.imgur.com/T4I5W.png
I want the following result:
http://i.stack.imgur.com/xDF55.png
Can this be achieved using a formula or PivotTables?
With pivot table you can easily extract the max date of each item. But the status will be problematic.
So, the best way to do it, is not with a pivot table. but with 3 steps.
1) copy your item list to another sheet to the first column. (I will assume the your first sheet is Sheet1 and the 2nd is Sheet2) choose the entire column in the 2nd sheet and remove duplicates. (date ribbon -> remove duplicates)
2) find your max data for each item.
lets assume your first rows is header so in the 2nd rows on column b enter:
=max(if(Sheet1!b:b=b3,Sheet1!a:a,""))
Note that this an array formula so you have to enter this using ctrl+shift+enter
Now drag this formula to the end of rows
3) find the last status of each item
you have to do double lookup formula
on c2 enter:
=index(Sheet1!c:c,match(a2&b2,Sheet1!b:b&Sheet1!a:a,0),1)
Again, that this an array formula so you have to enter this using ctrl+shift+enter
And again, drag this formula to the end of rows.
Actually this can be done only with formulas and without copying the data in another worksheet.
Assuming your data is in the range A1:C16 (change as needed) then you can enter the following Array Formulas (press [Ctrl]+Shift]+[Enter] together):
Enter "Item" in E1 and this array formula in E2 then copy down till last record (E16 for this sample)
=IFERROR(INDEX($B$2:$B$16,MATCH(0,COUNTIF(E$1:E1,$B$2:$B$16),0)*1),"")
Enter "Date” in F1 and this array formula in F2 then copy down till last record (F16 for this sample)
=IF($E2="","",MAX(IF($B$2:$B$16=E2,$A$2:$A$16,"")))
Finally Enter “Status” in G1 and this array formula in G2 then copy down till last record (G16 for this sample)
=IF($E2="","",INDEX($C$2:$C$16,MATCH($E2&$F2,$B$2:$B$16&$A$2:$A$16,0),1))
Ranges within the formulas should be adjusted as needed, no need to point to all rows in the worksheet.
I've been working on a excel problem, that I need to find an answer for I'll explain it below.
I've Table01 with the Columns :
Group No
Name
Price
I've Table02 with the columns:
Group No
City
Code
I've merged two tables of Table01 & Table02 as shown in the Image03 , But without order.
But,as you see Group No Column is similar in both tables.
What I need is to get the matching rows of Table01 & 02 considering 'Group No' Column.
The Final result is to be seen as the final image.
Is there a way to do this with excel functions ?
Thank You!
Put the table in the second image on Sheet2, columns D to F.
In Sheet1, cell D2 use the formula
=iferror(vlookup($A2,Sheet2!$D$1:$F$100,column(A1),false),"")
copy across and down.
Edit: here is a picture. The data is in two sheets. On Sheet1, enter the formula into cell D2. Then copy the formula across to F2 and then down as many rows as you need.
Teylyn's answer worked great for me, but I had to modify it a bit to get proper results. I want to provide an extended explanation for whoever would need it.
My setup was as follows:
Sheet1: full data of 2014
Sheet2: updated rows for 2015 in A1:D50,
sorted by first column
Sheet3: merged rows
My data does not have a header row
I put the following formula in cell A1 of Sheet3:
=iferror(vlookup(Sheet1!A$1;Sheet2!$A$1:$D$50;column(A1);false);Sheet1!A1)
Read this as follows: Take the value of the first column in Sheet1 (old data). Look up in Sheet2 (updated rows). If present, output the value from the indicated column in Sheet2. On error, output the value for the current column of Sheet1.
Notes:
In my version of the formula, ";" is used as parameter separator instead of ",". That is because I am located in Europe and we use the "," as decimal separator. Change ";" back to "," if you live in a country where "." is the decimal separator.
A$1: means always take column 1 when copying the formula to a cell in a different column. $A$1 means: always take the exact cell A1, even when copying the formula to a different row or column.
After pasting the formula in A1, I extended the range to columns B, C, etc., until the full width of my table was reached. Because of the $-signs used, this gives the following formula's in cells B1, C1, etc.:
=IFERROR(VLOOKUP('Sheet1'!$A1;'Sheet2'!$A$1:$D$50;COLUMN(B1);FALSE);'Sheet1'!B1)
=IFERROR(VLOOKUP('Sheet1'!$A1;'Sheet2'!$A$1:$D$50;COLUMN(C1);FALSE);'Sheet1'!C1)
and so forth. Note that the lookup is still done in the first column. This is because VLOOKUP needs the lookup data to be sorted on the column where the lookup is done. The output column is however the column where the formula is pasted.
Next, select a rectangle in Sheet 3 starting at A1 and having the size of the data in Sheet1 (same number of rows and columns). Press Ctrl-D to copy the formulas of the first row to all selected cells.
Cells A2, A3, etc. will get these formulas:
=IFERROR(VLOOKUP('Sheet1'!$A2;'Sheet2'!$A$1:$D$50;COLUMN(A2);FALSE);'Sheet1'!A2)
=IFERROR(VLOOKUP('Sheet1'!$A3;'Sheet2'!$A$1:$D$50;COLUMN(A3);FALSE);'Sheet1'!A3)
Because of the use of $-signs, the lookup area is constant, but input data is used from the current row.
Please take a look at the attached snapshot.
How to convert the Original Table to the Required Table, in the easiest manner ?
Here, I have shared just a small sample, the real table is quite big having more then 100 rows / symbols and 100 columns / dates.
Therefor it is not possible to manually copy paste the data to change the table format.
The final output table will have just 3 columns "symbol, date and value" arranged according to the dates in ascending order.
Please suggest how to do this. Thanks
here it is.
Put Original table in one sheet, say Sheet1. Top left cell being A1 = Symbol
Go to another sheet, say Sheet2.
In cell A1 put: Symbol
In cell B1 put: Date
in cell C1 put: Value
Go to cell A2 and put this formula:
=INDIRECT("Sheet1!A" & 2+MOD(ROW()-2; X);TRUE)
Go to cell B2 and put this formula:
=INDIRECT("Sheet1!R1C" & 2+ROUNDDOWN((ROW()-2)/X;0);FALSE)
Go to cell C2 and put this formula:
=INDIRECT("Sheet1!R" &2+MOD(ROW()-2; X)&"C" & 2+ROUNDDOWN((ROW()-2)/X;0);FALSE)
In all formulas above, replace X with the number of Symbols you got. In your original table there are 4.
Now fill down as needed
Note: If functions don't work, use comma(,) instead of semicolon(;).