Excel indexmatch, vlookup - excel

I have a holiday calendar for several years in one table. Can anyone help – How to arrange this data by week and show holiday against week? I want to reference this data in other worksheets and hence arranging this way will help me to use formulae on other sheets. I want the data to be: col A having week numbers and column B showing holiday for year 1, col. C showing holiday for year 2, etc.
Fiscal Week
2015 2014 2013 2012
Valentine's Day 2 2 2 3
President's Day 3 3 3 4
St. Patrick's Day 7 7 7 7
Easter 10 12 9 11
Mother's Day 15 15 15 16
Memorial Day 17 17 17 18
Flag Day 20 19 19 20
Father's Day 21 20 20 21
Independence Day 22 22 22 23
Labor Day 32 31 31 32
Columbus Day 37 37 37 37
Thanksgiving 43 43 43 43
Christmas 47 47 47 48
New Year's Day 48 48 48 49
ML King Day 51 51 51 52

It's not too clear what year 1 is, so I'm going to assume that's 2015, and year 2 is 2014, etc.
Here's how you could set it up, if I understand correctly. Use this index/match formula (psuedo-formula):
=Iferror(Index([holiday names range],match([week number],[2015's week numbers in your table],0)),"")
It looks like this:
(=IFERROR(INDEX($A$3:$A$17,MATCH($H3,B$3:B$17,0)),""), in the cell next to the week numbers)
You can then drag the formula over, and the matching group (in above picture, B3:B17) will "slide over" as you drag the formula over.

Related

"Max value day" of the week and tallying up each day that was highest Python

I was able to get the highest value of the week. Now, I need to figure out which day of the week it was so I can tally up how many times a certain day of the week is the highest.
For example,
Day of the week that has highest value of that week
Mon:5
Tue:2
Wed:3
Thur:2
Fri:1
This is what my dataframe looked like before I parsed the information that I needed.
Date Weekdays Week Open Close
0 2019-06-26 Wednesday 26 208.279999 208.509995
1 2019-06-27 Thursday 26 208.970001 212.020004
2 2019-06-28 Friday 26 213.000000 213.169998
3 2019-07-01 Monday 27 214.250000 214.619995
4 2019-07-02 Tuesday 27 214.380005 214.539993
.. ... ... ... ... ...
500 2021-06-21 Monday 25 275.619995 277.100006
501 2021-06-22 Tuesday 25 277.570007 276.920013
502 2021-06-23 Wednesday 25 276.890015 274.660004
503 2021-06-24 Thursday 25 275.000000 275.489990
504 2021-06-25 Friday 25 276.369995 278.380005
[505 rows x 5 columns]
Now I was able to get the highest value of the week, but I want to get the day and tally the which days were the highest.
#Tally up the highest days of the week at OPEN
new_data.groupby(pd.Grouper('Week')).Open.max()
The result was
Week
26 213.000000
27 215.130005
28 215.210007
29 214.440002
30 208.369995
31 210.000000
32 204.199997
33 214.740005
34 210.050003
35 217.509995
36 222.000000
37 220.539993
38 220.279999
39 214.000000
40 214.300003
41 215.880005
42 216.740005
43 212.429993
44 213.550003
45 222.809998
46 228.500000
47 233.570007
48 233.919998
49 231.190002
50 231.259995
51 227.679993
52 226.860001
1 233.539993
2 234.789993
3 235.220001
4 233.000000
5 236.979996
6 241.429993
7 244.729996
8 248.070007
9 251.080002
10 264.220001
11 260.309998
12 252.750000
13 259.940002
14 264.220001
15 270.470001
16 272.299988
17 276.290009
18 289.970001
19 292.350006
20 290.200012
21 290.190002
22 292.910004
23 292.559998
24 286.660004
25 277.570007
53 230.500000
Name: Open, dtype: float64
I got you. We wrap the groupby in df.loc, then select the indexes for the max values of Open in each group. Finally just take the value_counts of the Weekdays.
df.loc[df.groupby(["Week"]).Open.idxmax()].Weekdays.value_counts()

Counting combinations of values in table of values excel?

I have a table of values with each value in a different cell
e.g.
2 9 12 19 41 45 14 39
12 14 19 27 39 40 30 44
6 9 13 15 16 41 7 20
8 16 14 34 13 44 5 15
10 11 20 24 27 36 9 41
Is there a way to find which pairs of numbers are most common.
i.e.
13 & 15 appear 2 times
14 & 44 appear 2 times
24 & 27 appear 1 time
I was hoping for a formula as the table has over a hundred rows in it so would be time consuming to count manually.
The formula you would want would be the one for the row totals of a pair of numbers in A2 and B2:
=SUM(MMULT(--($E$2:$L$6=A2),TRANSPOSE(COLUMN(E:L))^0)*MMULT(--($E$2:$L$6=B2),TRANSPOSE(COLUMN(E:L))^0))
entered as an array formula using CtrlShiftEnter
There will be formulas for for listing distinct pairs up to a certain number out there - I used
=IF(ROW()=2,1,IF(B1<45,A1,A1+1))
for A2 and
=IF(B1<45,B1+1,2+COUNTIF(B$1:B1,45))
for B2.
If you scroll down this list you can see that 13,16 occurs twice as well as 13,15.
9,41 occurs three times.
Note - I am assuming the numbers are like lottery numbers and any one number can only occur once in a row. The formula could easily be modified to account for duplicates within a row.

How can I delete duplicates group 3 columns using two criteria (first two columns)?

That is my data set enter code here
Year created Week created SUM_New SUM_Closed SUM_Open
0 2018 1 17 0 82
1 2018 6 62 47 18
2 2018 6 62 47 18
3 2018 6 62 47 18
4 2018 6 62 47 18
In last three columns there is already the sum for the year and week. I need to get rid of duplicates so that the table contains unique values (for the example above):
Year created Week created SUM_New SUM_Closed SUM_Open
0 2018 1 17 0 82
4 2018 6 62 47 18
I tried to group data but it somehow works wrong and does what I need but just for one column.
df.groupby(['Year created', 'Week created']).size()
And output:
Year created Week created
2017 48 2
49 25
50 54
51 36
52 1
2018 1 17
2 50
3 37
But it is just one column and I don't know which one because even if I separate the data on three parts and do the same procedure for each part I get the same result (as above) for all.
I believe need drop_duplicates:
df = df.drop_duplicates(['Year created', 'Week created'])
print (df)
Year created Week created SUM_New SUM_Closed SUM_Open
0 2018 1 17 0 82
1 2018 6 62 47 18
df2 = df.drop_duplicates(['Year created', 'Week created', 'SUM_New', 'SUM_Closed'])
print(df2)
hope this helps.

SUMIFS/SUMPRODUCT for 2D data with multiple possible values in 2nd direction

I have been struggling with the following:
I have a data sheet as follows, from which I want to sum the amounts per week and groups of projects, where the group of projects is user input. This "data" sheet is schematically looking like this
A B C D E F G
1 YEAR 2017 2017 2017 2017 2017 2017
2 WEEK 40 41 42 43 44 45
3 ProjectA 100 101 102 104 100 85
4 ProjectB 80 80 85 82 80 82
5 ProjectC 60 60 60 60 60 60
6 ProjectD 105 108 112 116 120 122
Next step is that the question of which projects you'd need to sum, is user input, so in another sheet ("projects"), the user would input:
A
1 ProjectA
2 ProjectC
3
4
5
Then in the third sheet, I would have to show the summed data per week:
A B C D E F
1 2017 2017 2017 2017 2017 2017
2 40 41 42 43 44 45
3
Now the big question is, what formula could I use in row 3 of this last sheet?
What I have tried so far is: (in A3)
{=SUM(IF(data!B1:G1=A1;IF(data!B2:G2=A2;IF(data!A3:A6=projects!A1:A5;data!B3:G6))))}
This gives me a #N/A error. If I replace projects!A1:A5 by projects!A1, everything works fine, but then that's not much of a summation anymore :)
I have tried other versions with SUMIFS and SUMPRODUCT but those get me nowhere closer to where I'd like to be.
So, any help would be greatly appreciated.
(One last note, I am not able/allowed to change or add anything in the "data" sheet)
Use SUMPRODUCT:
=SUMPRODUCT((Data!$B$2:$G$2=A2)*(Data!$B$1:$G$1=A1)*(ISNUMBER(MATCH(Data!$A$3:$A$6,projects!$A:$A,0))),Data!$B$3:$G$6)

Calculate sum for entire sheet based on hours

I have a spreadsheet that has various weekly hours against a fixed number. For example
Name Weekly Hours Week 1 Week 2 Week 3
Jon 40 44 36 40
Shaun 40 40 36 44
Dawn 20 25 10 16
Is there a way where I can convert the weekly hours so that they have the sum of Weekly Hours - Week
Example for Jon
-4, 4, 0
Not sure how to do this and wondered if there was a global setting/sum?

Resources