Aligning cells into the same column based on similar values - excel

I recently pulled some data into excel and some of the cells ended up like :
{paypal:34, giftcard: 34, authorizenet: 44} (for payment methods)
I managed to divide them up into separate columns as such:
paypal: 34 | giftcard: 34 | authorizenet: 44 |
but not all lines have the same categories. Some have less payment methods while others have more.
So I basically have a large table of
paypal: 34 | giftcard: 34 | authorizenet: 44 |
authorizenet: 34 |
giftcard: 34 | authorizenet: 44 |
paypal: 34 | check: 3 |
Is there a way to align the cells in each row where if they contain "paypay", they align into a single column and so on? I was thinking about sorting but they won't exactly line up.
paypal: 34 | giftcard: 04 | authorizenet: 34 |
paypal: 31 | giftcard: 24 | authorizenet: 45 |
paypal: 74 | giftcard: 31 | authorizenet: 74 |
Thanks!

You should start by using the 'Text to Columns' functions in excel.
First, select all your data then go to: Date > Data Tools > Text to Columns.
Next, select 'Delimited' > Next >
Next, check only 'Comma' > Next >
Finally, Click 'Finish'
Now you have all of the different payment types in separate columns/ cells and need to 'align' all your 'Paypal' in the same column and 'Authorize.Net' in the same column and so on. Use the following formula to get this 'alignment' part done:
=IF(LEFT(C7,6)="Paypal",C7,IF(LEFT(D7,6)="Paypal",D7,IF(LEFT(E7,6)="Paypal",E7,"")))
=IF(LEFT(C7,6)="Giftca",C7,IF(LEFT(D7,6)="Giftca",D7,IF(LEFT(E7,6)="Giftca",E7,"")))
=IF(LEFT(C7,6)="Author",C7,IF(LEFT(D7,6)="Author",D7,IF(LEFT(E7,6)="Author",E7,"")))
You will need to edit the directly reference cells that I show above to fit your own worksheet needs. My parsed (after splitting my data from delimiters) data was in columns C, D, and E. Therefore, I used C7, D7, and E7 to use the 'left' formula on. These formulas on my worksheet were in cells G7, H7, and I7. Give is a try and let me know.
Tip: on the 'Left' formula, make sure the text string is exact (capitals, spaces, etc).
Good luck!

Related

Grouping excel files by Week Number

I am trying to work on a Excel that has a giant amount of data with dates, to simplify I want it to group the different numbers into weeks, allow me to explain:
The actual rows are like:
29-11-2018 | 49 | 1 | 4 |7 | 2
30-11-2018 | 49 | 4 | 0 |2 | 1
Where "49" is the week number from the date. I'm trying to make Excel put together those lines by week and add the other lines, like this:
49 | 5 | 4 | 9 | 3
And this for all the weeks, so I can know the exact number of data for every week.
Is there a way of doing this?
Thanks!
Regards,
Assuming your data is located at A2:F3..
H2 ---> =B2
put
I2 ---> =IF($B1<>$B2,C2,I1+C2)
and drag to L2, then
N2 ---> =IF($B3<>$B2,H2,"")
and drag to R2. Select H2:R2 and drag to the end..
you'll see your intended result in column N to R.

Excel - Conditional Format Top Value IF Both Cells Are Not Blank

I have a sheet that shows the daily sales on one row and if that month is the current month will show the last years sales on the row below that - else it will be "".
I then want to format the values to highlight the top 1 value, but only if both cells are not blank (or "").
Example (snippets):
A B C D
====================================================
1 = Jan | 1-Jan-18 | 2-Jan-18 | 3-Jan-18
2 = 2018 | Mon | Tue | Wed
3 = MI | 0 | 4 | 4
4 = SC | 0 | 0 | 0
5 = Subtotal | 0 | 4 | 4
6 = DS | 0 | 0 | 0
7 = Total | 0 | 4 | 4
8 = Daily Sales | $- | $1,763.72 | $1,763.72
9 = "" | "" | "" | ""
. . .
51 = Jun | 1-Jun-17 | 2-Jun-17 | 3-Jun-17
52 = 2017 | Thu | Fri | Sat
53 = MI | 29 | 33 | 33
54 = SC | 40 | 34 | 38
55 = Subtotal | 69 | 67 | 71
56 = DS | 37 | 35 | 39
57 = Total | 106 | 102 | 110
58 = Daily Sales | $46,738.63 | $44,974.91 | $48,502.35
59 = Last Year | $34,899.21 | $34,557.87 | $36,945.18
Please note the "" aren't actually there. I'm just showing the values are blank.
So cells B8:D9 should not be highlighted, as row 9 is blank. Cells B58:D58 should be highlighted, as both row 58 and row 59 are not blank and row 58 is the higher value.
How do I go about doing this? I was trying just a "Top 1" value, but it highlights the values in row 8 which just looks weird as there is no values in row 9 to compare with.
Solution should be fully automatic. I don't want to manually have to update conditional formats, cells, etc.
Select cell B8 and create a new conditional formatting rule using a formula. Put in this formula:
=AND(COUNT(B8:B9)=2,B8=MAX(B8:B9))
Select cell B9 and create a new conditional formatting rule with this formula:
=AND(COUNT(B8:B9)=2,B9=MAX(B8:B9))
Set the desired formats for both rules. Apply the rules to more cells or just copy the two cells and use Paste Special > Formats to apply to any other pair of cells that are one below the other.
I got it to work using =AND(B9<>"",B8>B9) for cells =$B$8:$B$9 (example range) and just copied that for other cells (eg. =AND(C9<>"",C8>C9) for cells =$C$8:$C$9.

Excel Ranking tie assistance

Can anyone help me to do the following in relation to ties when using the Excel Rank function?
Col A contains scores and B contains the rank. I am quite happy with this except that I would like to show an '=' next to the ranking where it is a tie:
Score Rank
66 3
64 4=
63 6
68 2
64 4=
81 1
etc
Many thanks.
You can combine your RANK with COUNITF. Place the following into cell B3 as per the example
=RANK(A3,$A$3:$A$7)&IF(COUNTIF($A$3:$A$7,A3)>1,"=","")
Note, if you are using Excel 2013 or 2016, it would be a good idea to replace RANK with RANK.EQ
This can be done in another column next to the column where you have ranked it.
Step 1: Rank the numbers in a simple manner using RANK.EQ
Output:
(A)|(B)
66 | 3
64 | 4
63 | 6
68 | 2
64 | 4
81 | 1
Step 2: In another column use the code IF(COUNTIF(A:A,A1)>1,CONCATENATE(B1,"="), B1)
Output:
(A)|(B)|(C)
66 | 3 | 3
64 | 4 | 4=
63 | 6 | 6
68 | 2 | 2
64 | 4 | 4=
81 | 1 | 1
You can paste the values and remove the columns as required.
Hope it helps. :)

Need some kind of pivotal table without agregation in Excel

I struck with problem of getting reports from table, that look like this:
C1| C2 | C3 | C4
A | 2015-05-15 | 34 | 4
A | 2015-03-12 | -4 | 5
A | 2014-03-12 | 24 | 8
B | 2015-11-10 | -4 | 5
B | 2015-06-12 | 3 | 5
C | 2013-05-12 | 3 | 5
...
600+ rows
...
So I need to make a diagram by different value columns (C3 and C4) grouping by values in the first column. In usual case it is achieved with to separate table which a looks like this (e.g. for col3):
A | B | C | ....
34 | -4 | 3 | ....
-4 | 3 | | ....
24 | | | ....
For col4, I need a table with the similar layout. So in short, I need to make some pivotal table by without aggregation on value per term. Is it possible to get such small table with the original table? If you can offer some other layout for original data which will be more suitable (and easier, in ideal with standard excel functions) for this task, fell free to offer - with some Python script I can resave it.
Find a simple solution: just download tool Tableau. It affords to create very flexible graphs based on raw data, freely place any col as row and vice versa, groping also available.
First, I will assume that C1,C2,C3,C4 are column headings in A1:D1 and the data is in A2:D1000
In F1:H1 place C3,C3,C3
In F2:H2 place A,B,C
In J1:L1 place C4,C4,C4
In J2:L2 place A,B,C
In F3 place the following array formula:
=IFERROR(INDEX(OFFSET($A$2:$A$1000,0,MATCH(F$1,$A$1:$D$1,0)-1),SMALL(IF($A$2:$A$1000=F$2,ROW($A$2:$A$1000)-ROW(A$2)+1),ROWS(F$2:F2))),"")
Don't forget to use Ctrl+Shift+Enter to make it an array formula instead of just using Enter for a normal formula.
Copy F3 to F4:F7, G3:H7 and J3:L7
You end up with something that looks like this:
| A B C D E F G H I J K L
----|--------------------------------------------------------------------
1 | C1 C2 C3 C4 C3 C3 C3 C4 C4 C4
2 | A 15/05/2015 34 4 A B C A B C
3 | A 12/03/2015 -4 5 34 -4 3 4 5 5
4 | A 12/03/2014 24 8 -4 3 5 5
5 | B 10/11/2015 -4 5 24 8
6 | B 12/06/2015 3 5
7 | C 12/05/2013 3 5
Decomposing the formula in F3:
=IFERROR(INDEX(source column,SMALL(filtered row numbers,ranking)),"")
Where:
source column is OFFSET($A$2:$A$1000,0,MATCH(F$1,$A$1:$D$1,0)-1)
filtered row numbers is IF($A$2:$A$1000=F$2,row numbers)
row numbers is ROW($A$2:$A$1000)-ROW(A$2)+1
ranking is ROWS(F$2:F2)
How the formula works is a multipart explanation:
IFERROR(formula,"") If the embedded formula produces an error then we display an empty cell instead. This is useful since we don't know how many results we will get.
INDEX(range,row) Get the value in the row we want to see. The row number here is dynamically generated based on whether the data matches the criteria.
SMALL(array,k) Extract the kth smallest value in the array. The array is the filtered values. k is just a number depending on which row in F we put the formula in.
IF(criteria,value) Based on the criteria either produces the value or FALSE.
ROW(cell) The row number of the cell
ROWS(range) The size of the range
So in the array formula:
ROW($A$2:$A$1000)-ROW(A$2)+1 is a list of all the row numbers in the range starting at 1
IF($A$2:$A$1000=F$2,ROW($A$2:$A$1000)-ROW(A$2)+1) is a list of just those row numbers that match the criteria
SMALL takes the filtered list and returns the kth smallest filtered row number which means that F3 gets the first one, F4 gets the second one, etc
INDEX grabs the data at that row number and displays it
I got the idea for this from http://www.exceltactics.com/make-filtered-list-sub-arrays-excel-using-small/ and on that page is a really good explanation of how it all works.

How to automatically delete rows in Excel

Consider the following (partial) Excel worksheet:
A | B | C | D
---+-------------+-------+-------
id | date | var_a | var_b
1 | 2011-03-12 | 200 | 34.22
1 | 2011-03-13 | 203 | 35.13
1 | 2011-03-14 | 205 | 34.14
1 | 2011-03-15 | 207 | 54.88
1 | 2011-03-16 | 208 | 12.01
1 | 2011-03-18 | 203 | 76.10
1 | 2011-03-19 | 210 | 14.86
1 | 2011-03-20 | 200 | 25.45
. | . | . | .
. | . | . | .
2 | 2011-03-12 | 200 | 34.22
2 | 2011-03-13 | 203 | 35.13
2 | 2011-03-14 | 205 | 34.14
2 | 2011-03-15 | 207 | 54.88
2 | 2011-03-16 | 208 | 12.01
2 | 2011-03-18 | 203 | 76.10
2 | 2011-03-19 | 210 | 14.86
2 | 2011-03-20 | 200 | 25.45
. | . | . | .
. | . | . | .
In reality, there are over 5.000 rows. I need to delete all rows which date falls on a saturday or sunday. In the example, March 12 and 13 (2011-03-12/13) and March 19 and 20 are Saturdays and Sundays. I cannot just delete every nth rows, since there might be days missing in the list (as is the case here with 2011-03-17).
Is this possible to do with either a formula or VBScript? I have never written a VBScript macro before (I have never had a use for it) so I would appreciate some help.
If you only need to do this once, this is what I would do. This should preserve the order, but if you're really worried about it, read very end of the post:
Add a new column, call it "Is Weekend". In it, put =if(WEEKDAY(B2, 2) > 5, 1, 0). Drag that formula down for the entire table.
Filter the columns. To do that, select the entire table (click on any table cell then hit Ctrl-A), then
On Excel 2007+, go to Data-> click "Filter"
On Excel 2003, go to Data->Filter->Auto Filter.
Sort everything by last column (Is Weekend) in descending order. This should put all weekend rows together without altering the order among the other rows.
Delete all rows with 1 in "Is Weeked" column. Delete that column.
If you're really worried about preserving order, before you do the above, you can do the following:
Add a new column called "Position". Put 1 in the first row, 2 in the second row, select them and drag it down to the bottom so every row has its own position number in increasing order.
Perform the filtering as above.
After you're done, sort everything in ascending order by "Position" column.
The trick is that you don't need to delete those rows, you need to replace their values for C and D with 0. This is easiest done with IF() and WEEKDAY() within two new columns C' and D' referencing C and D. Feel free to then just delete C and D.
You can do this in one go using an array formula. In cell E2, enter the following formula (on one line), and confirm with Ctrl-Shift-Enter (as opposed to the regular Enter)
=INDEX($A$2:$D$5000, SMALL(IF(WEEKDAY($B$2:$B$5000,2)>5, "",
ROW($B$2:$B$5000)-MIN(ROW($B$2:$B$5000))+1), ROW(A1)),COLUMN(A1))
5000 indicates the number of rows in your spreadsheet. After this, the formula should have curly braces around it to indicate it is an array formula. E2 should have the value 1. Then select cell E2 and drag the lower-right corner of the cell to the right until 4 cells are covered. Then drag the lower-right corner of the 4-cell-selection all the way down. At the bottom you will see rows containing #NUM!, one for each deleted row. You can delete those in the regular way.
In stead of starting off in cell E2, you could start off in cell A2 of a new sheet. In that case, you need to prepend the original sheet name to each reference in the formula, as in OriginalSheet!$A$2
This formula is an adaption from the one given in Excel: Remove blank cells
In case you decide to delete the rows, please make sure to run the VBA code from the last row to the first row. Here is a piece of code just written from memory to show you the idea of running from bottom to the top.
For i = Selection.Rows.Count To 1 Step -1
If WEEKDAY(Cells(r, 2),2) > 5 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i

Resources