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
Related
I'm trying to create a formula in column K which sums all cells that apply , in column J, only when the following conditions are true:
dates are the same in column A
AND client name is the same in column B
For example, in cell K2, I want the sum of J2+J3+J4 because A2=A3=A4 and B2=B3=B4.
K5=J5 only, because there are no other dates with the same client name.
K6=J6+J7 because A6=A7 and B6=B7.
What kind of formula would I use for this? I can't figure out how to do it with a SUMIFS.
I would try using a pivot table with:
The names as row values
The dates as the column values
And funds received using SUM in the values column
Edit
Based on #pnuts comments here is how to get the values in column K. Put this in K2 and drag down.
=IF(OR(COUNTIFS($B$1:B3, B3) = 1, B3 = ""), SUMIFS($J$2:J2, $A$2:A2, A2, $B$2:B2, B2), "")
This formula will give blank values until the formula finds a new client on a new date. However, I still think using pivot table is a better solution.
However, I still find the pivot table
In cell K2 put following formula:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,SUMIFS($J$2:$J$10,$A$2:$A$10,A2,$B$2:$B$10,B2),"")
Adjust row 10 value. It will be last row of your actual data.
Copy down as much you need.
EDIT
Uploaded file shows the cause behind formula not working correctly for you. It turned out to be whitespace characters in column B (names) data e.g.
Cell B3: "Moe John" has a trailing space.
Cell B10: Same case with "Doe Jane"
If you want to use above posted formula then all names shall be corrected. Or alternatively to deal with spaces you can adopt below approach.
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,"*"&TRIM(B2)&"*")=1,SUMIFS($J$2:$J$28,$A$2:$A$28,A2,$B$2:$B$28,B2),"")
Notice the change in COUNTIFS formula where B2 is now replaced with "*"&TRIM(B2)&"*".
Even such formula will take a beating if you have uneven whitespace characters in between your data. I'd suggest normalizing it as much as possible.
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.
Suppose I have two columns; A and B. each of which has 50 rows of data. I want to set the value of a third column, C, to the value of A corresponding to, say, the minimum value of B. Can I do this without writing a macro?
https://qph.is.quoracdn.net/main-qimg-7978d7e50a58000fc152952a980c09e3?convert_to_webp=true
Consider in C1:
=IF(B1=MIN(B:B),A1,"")
and copy down:
As you see, no macro is required.
If you have unique values in Column B i.e. there's only one minimum value in the column, you can use following formula. Enter this formula in Cell C1:
=INDEX(A:A,MATCH(MIN(B:B),B:B,0))
Or if you have a fixed range say till row 25, use following formula and change number of rows as required:
=INDEX(A1:A25,MATCH(MIN(B1:B25),B1:B25,0))
If you've repeating minimum value in Column B i.e. minimum value occurs more than one then try this array formula. Enter the formula in Cell C1 and drag it down till the row you want:
=IF(COUNTIF($B$1:$B$25, MIN(B:B))>=ROWS($A$1:A1),INDEX($A$1:$A$25, SMALL(IF(MIN(B:B)=$B$1:$B$25, ROW($B$1:$B$25)-MIN(ROW($B$1:$B$25))+1, ""), ROW(A1))), "")
This is an array formula so commit it by pressing Ctrl+Shift+Enter
Again if you want to use this formula for fixed rows say 25 then use following formula. Change number of rows as accordingly:
=IF(COUNTIF(B:B, MIN(B:B))>=ROWS($A$1:A1),INDEX(A:A, SMALL(IF(MIN(B:B)=B:B, ROW(B:B)-MIN(ROW(B:B))+1, ""), ROW(A1))), "")
Got the tips for array formula from here.
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.