Need help optimizing vacation planning Excel (sumproduct of 10000+ rows) - excel

In this picture you can see in column F to H what the raw data looks like and column A to D is what I need (but horizontal).
I transformed the data to show exact dates when employee is on vacation and not date ranges for example:
John 02.01.2018 03.01.2018 04.01.2018 05.01.2018
John 07.01.2018 08.01.2018 09.01.2018 10.01.2018
Tom 01.01.2018 02.01.2018 03.01.2018 04.01.2018 05.01.2018
Tom 07.01.2018 08.01.2018 09.01.2018
Mark 04.01.2018 05.01.2018 06.01.2018
Mark 08.01.2018 09.01.2018 10.01.2018
This way I can use sumproduct to fill my planning table and it works.I managed to do it for managers because the raw data is only 400 rows I use this formula:
=IF(SUMPRODUCT((OFFSET(VMX!$G$2;0;0;COUNTIF(VMX!$G:$G;">""")-1;1)=Planner!$A3)*(INDIRECT("VMX!$O$2:$AS$"&COUNTIF(VMX!$G:$G;">"""))=Planner!G$1)*(OFFSET(VMX!$M$2;0;0;COUNTIF(VMX!$M:$M;">""")-1;1)="X"))>0;"X";IF(SUMPRODUCT((OFFSET(VMX!$G$2;0;0;COUNTIF(VMX!$G:$G;">""")-1;1)=Planner!$A3)*(INDIRECT("VMX!$O$2:$AS$"&COUNTIF(VMX!$G:$G;">"""))=Planner!G$1)*(OFFSET(VMX!$M$2;0;0;COUNTIF(VMX!$M:$M;">""")-1;1)="Y"))>0;"Y";IF(SUMPRODUCT((OFFSET(VMX!$G$2;0;0;COUNTIF(VMX!$G:$G;">""")-1;1)=Planner!$A3)*(INDIRECT("VMX!$O$2:$AS$"&COUNTIF(VMX!$G:$G;">"""))=Planner!G$1)*(OFFSET(VMX!$M$2;0;0;COUNTIF(VMX!$M:$M;">""")-1;1)="O"))>0;"O";"")))
I simplified this formula using name manager to this:
=IF(SPX>0;"X";IF(SPY>0;"Y";IF(SPO>0;"O";"")))
In sheet VMX is the data.
The data ranges should be dynamic because I used offset and indirect but when I try to use this for all employees which is 10k+ rows the excel just freezes.
Does anyone know more efficient way to do this?

First convert your raw data to a table (tblVacDates). Then you can use a formula like this, using COUNTIFS.
=IF(COUNTIFS(tblVacDates[Name];B$1,tblVacDates[Start];"<="&$A2;tblVacDates[End];">="&$A2)=0;"";"X")
Paste the formula to the other columns (don't drag). Then you can copy/drag down

Related

Excel Adjacent Formula

I am desperately trying to find a formula that solves my problem.
Sheet1 structure:
name date weight
John 31.07.2020 80
Jack 01.08.2020 75
...
Sheet2 structure:
date John Jack ....
31.07.2020
01.08.2020
What I need to do is, for every date and name combination in Sheet2, I need to copy the weight information from Sheet1 into name's column of Sheet 2.
Example outcome:
date John Jack ....
31.07.2020 80
01.08.2020 75
I have used a couple of formulas but I could not make it work.
Can you help me with this?
Thank you
First, turn your data entry table into an Excel Table object by using Ctrl-T or Insert > Table.
Then, with one cell of that table selected, use Insert > Pivot Table.
Drag the Date into the Rows area, drag the Name into the Columns area and the Weight into the Values area. Format the pivot table to have no grand totals (Design Ribbon visible when a cell in the pivot table is selected).
When you add new data to the data entry table, the Table object will expand automatically and you can simply refresh the pivot table to include the new data.
It's really quite simple with SUMIFS.
If Sheet 1 looks like this:
...then you use this formula:
=SUMIFS(Sheet1!$C$2:$C$3,Sheet1!$A$2:$A$3,Sheet2!B$1,Sheet1!$B$2:$B$3,Sheet2!$A2)
=SUMIFS(Sheet1!R2C3:R3C3,Sheet1!R2C1:R3C1,Sheet2!R1C,Sheet1!R2C2:R3C2,Sheet2!RC1)
=SUMIFS(Table1[weight],Table1[name],Sheet2!B$1,Table1[date],[#date])
=SUMIFS(Table1[weight],Table1[name],Sheet2!R1C,Table1[date],[#date])
I get this:

How do I extract data from multiple worksheets into a dynamic list?

I'm looking for a way to extract data from several worksheets and sort them according to date in a dynamic list that changes automatically when the worksheets are edited/expanded. I would like to use a formula for this. Preferably the new list should also disregard blank rows.
Example (I'm using UK date format):
Worksheet A Worksheet B
---------- ----------
Column A Column B Column A Column B
11/01/2019 Apples 12/01/2019 Lemons
14/01/2019 Pears 14/01/2019 Grapefruits
23/02/2019 Plums 22/02/2019 Oranges
... ...
Sort into:
Worksheet C
----------
Column A Column B
11/01/2019 Apples
12/01/2019 Lemons
14/01/2019 Grapefruits
14/01/2019 Pears
22/02/2019 Oranges
23/02/2019 Plums
...
I have been playing around with sub-arrays and such but can't get to the bottom of the solution for my particular problem. I don't want to use VBA nor any built in Excel sort features.
I hope this is not too overkill for a formula.
Thanks.
As mentioned by #chrisneilsen this task can be handled by #powerquery.
Please refer to this article to find out how to use Power Query on your version of Excel. It is availeble in Excel 2010 Professional Plus and later versions.
The steps are:
Add both tables from your worksheet A and B to the power query editor;
Use Append Queries function under the Home tab to combine the two table (into a new one by choice);
Sort Column A ascending;
Close & Load the combined table into a new worksheet (by default).
Each time you make changes to the source tables on Worksheet A and/or B, you just need to go to the combined table, right click somewhere within the table and select Refresh to update the output (and there are other ways to refresh data that you can google the know how).
Let me know if you have encountered any problem.
Cheers :)

Is there a way to make excel expand dates in a spreadsheet

I have a large two column data set that already has dates and data, whoever I need the dates to "expand" for daily data
I already attempted to auto-fill however it doesn't do what I need it to
I have a spreadsheet like this
date Data
07/01/19 5
07/03/19 10
09/05/19 7
I'd like to expand the dataset like
date Data
07/01/19 5
07/02/19
09/03/19 10
07/04/19
07/05/19 7
Create another sheet with all of the dates that you need in column A. Then use this formula to look up your Data (column B) against these dates:
=IFERROR(VLOOKUP(A1,Sheet2!A:B,2,0),"")
It will match the desired output you have posted above.
With your data in columns A:B, you can use the following formulas:
D2: =IFERROR(INDEX(ROW(INDEX($A:$A,MIN($A:$A),1):INDEX($A:$A,MAX($A:$A),1)),ROWS($1:1)),"")
E2: =IFERROR(VLOOKUP(D2,$A:$B,2,FALSE),"")
and fill down
note that this formula will fail after 25 Nov 4770, but you'll probably be using a different tool by then :-)

Extract Pivot Table Row Label (not value)

In Excel 2010, I have a pivot table, in compact form, with 3 Row Labels (that represent a management hierarchy). Which of the 3 management levels is displayed in a particular row will change from day to day. (The source data is on another spreadsheet with the fields Manager L3, Manager L2 and Manager L1 in columns with John Smith, Gary Glen and Bob Stevens under them, respectively.)
In the column next to the pivot table, I need to capture which row label is being shown.
Pivot Table example
Is there a formula I can use to produce that info?
Let me know if you need more information. Thank you in advance.
Like I said above, I believe your solution would be to create an array on another (hidden) sheet like:
Then run a VLOOKUP to it: =VLOOKUP(A45,Sheet1!$A$1:$B$6,2,FALSE)
You'd put that formula in cell B45 on your sheet and drag down.

Excel Converting rows to columns with groups

Let's say that I have my columns in excel set up like this:
Name A B C D
George 10 5 4 6
And I want it to instead be like this:
Name Category Amount
George A 10
George B 5
George C 4
George D 6
Is there an easy way to do a copy and paste with transpose, or with a pivot table, or does it have to be done with VBA? I've been trying to only do it with VBA but I havent gotten very far.
How about a real answer instead of a link?
Highlight the two rows to pivot.
Copy
Find open row
Paste Special -> Transpose
As per comment, you can follow that link. A related SO answer that describes similar steps for Excel 2010 is How can I transform rows into repeated column based data?.
If you want to maintain a "dynamic" link between your source and target data, so whenever your source data changes, your target also does it automatically, you need formulas.
In that case, you can use Item 7 from Excel: Formulas for converting data among column / row / matrix :
To get in matrix_data3 the transpose of matrix_data2, one only needs to use matrix_data2_top_left and matrix_data3_top_left, with the formula
=OFFSET(matrix_data2_top_left,COLUMN()-COLUMN(matrix_data3_top_left),ROW()-ROW(matrix_data3_top_left))
and copied to a suitable target range.
Note that matrix_data2_top_left and matrix_data3_top_left are convenient Excel range names for the upper left cells of the source and target ranges, respectively, and they can be replaced in the formula by their absolute references (e.g., $B$1 and $B$6).
Also, matrix_data2 and matrix_data3 are Excel range names, but these ranges (either as names or absolute references) are not needed here.

Resources