Formula for getting worksheet names based on pivot table results - excel

I have an excel file with 30 time cards, each on their own worksheet, where the only identifier is the worksheet name (ie the employee name). Each worksheet has a first column of account numbers, followed by columns for hours worked for each day of the month, and then total.
From these individual employee tabs I make a Totals worksheet(using =SUM('Adams:White'!B1) and then fill left and fill down. . .)
I then make a pivot on the Totals data and get summary data for the department. (ie we spent 100 hours total on account# 12345) - no problem.
My Question is: How do I write a formula(s) to find which employees contributed to the hours spent on account# 12345. The specific output I would want is a table with a column heading of "12345", and then only the names of those who worked on that account below the heading. (Or all names, sorted, with a second column of how many hours they worked on "12345").
Thanks!
Steve

Since you are feeding your data set into a pivot table, you will need to ensure each record (row) in your data set is reportable. i.e. if Adam and Jane worked on account 12345 for a total of 7 hours and your record in your data set (table) is only one row with the account listed and the total number of hours, it will be difficult and extremely bad practice to attempt to report this by staffer (how do you know that the 7 hours is made up of Adam and Jane, or it could be 14 part-time workers that each put in half an hour).
You have two approaches. One: you could consolidate the data into a master data tab and from there you could have each sheet (Adam, Jane, White) be a report off the master table to show performance by staffer.
Two: Make use of power pivot, if you have Excel 2013+ installed. Here you would create a link for each table by account. Now you would have each rep's hours contributed as a field in the power pivot connection.
Please let me know which of the two seems a better choice and I can assist from there.

Related

How to Group Measures and Make Columns Table Source Name

I'm new to Tableau! I hope this is a simple answers. Thanks in advance!
I'm working with employee data and I need to create a matrix of headcount totals across years and months.
Final Matrix Output Example
I'm starting with 6 tables listing all active employees at the beginning of each year from 2015 through 2020. I then have a list of employees and the date that were hired; so all employee additions. I then have the same thing for terminations. All 8 of these tables are in the same Excel file but different tables.
List of Data Tables
How can I take this data and create the matrix I linked above? I've tried creating calculated fields to count the number of active employees for each time period, but I can't then seem to get the matrix to organize itself correctly in a table.
Current Status
I feel like the easiest solution would be to query this so that I just have a snapshot of all active employees at the beginning of each month and year with month and year columns, but I'm not sure how to convert what I have now, into that sort of structure.
Thanks again.
I fear you have to extensively restructure your data before proceeding to build a view/crosstab, as is evident from the current status of your data (screenshot shared by you). You can do it much easily in excel. Meanwhile, I recommend/suggest you to read the paper by Hadley Wickham, renowned statistician/data scientist at this page https://vita.had.co.nz/papers/tidy-data.pdf
Still, I am trying to give you the steps which you can follow-
Step-1 Rename all columns of headcount tables by removing years from these. (Keep year names in sheets instead). This will give same column names for your all headcount tables.
Step-2 UNION all these headcount tables in data-tab of tableau. Keep sheet_names in a separate columns which will later-on be used to extract years' values.
Step-3 PIVOT all months columns to rows (In data tab only)
Step-4 Extract year names from file/sheetname column
Step-5 This will give a table structure with three useful columns to build your crosstab i.e. 1. Year (to be placed in columns); 2. Months (to be placed in rows) and 3. Headcount value (to be placed on viz/text marks card)

Pivot Table project - Avoid using many INDEX and MATCH functions that make Excel crash

I need some help with an Excel Project that's giving me headaches. I succeeded to achieve everything I wanted but the result is too heavy for Excel and it crashes all the time. I'm over-using the INDEX and MATCH functions on large tables (50 000+ lines) and Excel doesn't like it. I'm looking for a way to do the same thing in a lighter way for Excel.
Here's what I achieved : I created a report that helps me analyzing my employees's performance VS their billing targets. To create such a report, I used a Pivot Table.
That Pivot Table needs this information as its source :
Each sales that every employee made (amount in $ and date)
The hourly rate of each employee (which changes for every period, see TABLE1 below)
The billing target for each employees (which changes for every period, see TABLE1 below)
Here's my setup. I have 3 tables :
TABLE1 (See attached image) - A table where I manually input data for each of my employees (hourly rate and billing target). Their billing target and hourly rate change every period. So, each period has a different line and I indicate the first day of the period and the last day of the period.
TABLE2 (See attached image) - Table that contains sales data exported from another software I use. Each line represents an amount sold by an employee to a customer on a specific date. This table is pretty heavy and contains more than 50 000 lines. Moreover, the last 2 columns of this table use Index and Match functions to get the right hourly rate and the right billing target from TABLE1. That means that each of those 50 000 lines uses the INDEX and MATCH functions twice… This part is too heavy for Excel and I need a workaround.
Moreover, TABLE2 is getting refreshed every few days with new data coming from my other software (an ERP). So the solution I need to find must take that into account and must be permanent (I try to avoid steps that will have to be done everytime I refresh TABLE2 with new data).
TABLE3 - A Pivot Table that uses TABLE2 as its data source. I use the slicer to select the name of an employee and a timeline to specify which months I want to display. Then the Pivot Table shows my employee's statistics grouped by months. The main statistic is the amount of "billed hours" for each employee, which is in reality the amount of sales made by that employee, divided by their hourly rate on a specific date.
My thoughts :
It is absurd that TABLE2 uses that many INDEX and MATCH functions. For example, if Employee1 made 500 sales between 2020-07-01 and 2020-07-31 (the same month, thus the same period, thus the same hourly rate and billing target), there will be 500 different lines that will use INDEX and MATCH to get the same hourly rate and billing target from TABLE1. That leads to a lot of duplicated calculation and a lot of duplicated data.
Would it be possible for a Pivot Table Calculated Field to use INDEX and MATCH in its formula? And would it be lighter for Excel to do so?
Another way would be to add, at the bottom of TABLE2, 12 lines per year (1 for each month) for every employee where I would write their hourly rate and the billing target. That way, the Pivot Table would be able to display an hourly rate and a billing target for each month, for each employee. That solution would work and would be lighter for Excel, but it would create a high risk of making mistakes while manually inputting the data.
I'm open to all suggestions including VBA!
Thank you very much for your precious time!
EDIT : FORMULA
As requested, here's my INDEX AND MATCH formula that is in TABLE2 and gets the hourly rate from TABLE1 :
=INDEX(TAB_Employee_Data[[#All];[Hourly_Rate]];MATCH([#[Date (Cell)]]; IF(TAB_Employee_Data[[#All];[Name]]=[#[Employee(Cell)]];TAB_Employee_Data[[#All];[First day of the period]]);1))
TAB_Employee_Data is the tab that contains "TABLE1".
I translated the names of the fields since all my work is in French.
This formula does the following : it searches the name of an employee in TABLE1 and finds the period which fits the date of a line in TABLE2.
Also, to work properly, I need to sort the lines of TABLE1 in chronological order.
TABLE 1 :
TABLE 2:

Calculating Weekly Average by user given daily data input in excel pivot table

So I started using Pivot Tables a few weeks ago, but I'm pretty decent at Excel otherwise. I hit an issue that should be an easy fix and I don't see it. I have a document that is tracking Key Performance Indicators for my warehouse packing department. I have 2 tabs in the document that matter (Input Log, and Analysis).
Input log is basically copied from a report generated from my warehouse system. Gives me a USER, DATE, HRS WORKED, ORDERS PACKED, ITEMS PACKED. Using a pivot table I want to see the average hours worked by week for each user.
Currently I can only see the Sum of the hours works and the daily average. How do I also see the weekly average?
[InputLogData][2]
I was able to get the workbook hosted on google drive Packing KPI Workbook
If you create the pivot table, but select to "add to data model",
you will see, in the "Value Fields Settings" selection, a Distinct Count item.
You can then do a Distinct Count of the WE column, and add a column to divide the total hours worked by User, by the total number of Weeks. (See the formula in D4: =B4/C4 )
EDIT: If you want to have the results within the Pivot Table itself, you can add a few calculated columns to your input log.
WE per User is the Unique number of weeks each user works. This formula is an array formula and must be entered by holding down ctrl + shift while hitting enter. Excel will place braces {...} around the formula seen in the formula bar:
=SUM(--(FREQUENCY(IF(User=D2,WE),WE)>0))
Hrs Worked This Wk is the hours worked in the week by the user. This is not really needed, but is in there for when I was troubleshooting the calculations.
=SUMIFS(Hrs_Worked,WE,A2,User,D2)
This will be used to calculate the average for the AvgHrs/Wk column:
=SUMPRODUCT((User='Input Log'!$D2)*Hrs_Worked/WE_Per_User)
This can then be used to create the Pivot Table:
In the Pivot Table, the
Total Hrs is the SUM of Hrs Worked
Hrs-Daily is the Average of Hrs Worked,
Weekly Hrs is the Average of AvgHrs/Wk

Taking Data from pivot table and inserting under specific headers

I just recently created a macro to make my pivot table and its working pretty good.
Heres how the format of the pivot table pretty much looks. This file is called Sheet1
Name Hours
Bob 100
Jones 200
Jilly 300
etc etc
Now I have another file which is Called Company, and it comes with many headers at the top, which is read from a corporate website. Unfortunately among the headers it is missing a name and hours column. Heres how it currently Looks
Employee No. Company Code Cost Centre Level Organization Code etc etc
I want it to look like Employee No. Name Hours Company Code ...
And the name and hours should just be taken from the pivot table. Any thoughts on how I could make a script to do this? Thanks.
MORE INFO
Originally there is a file named Cado
Cado has many headers i.e
Pers.No Employee Date Hours Time ... ...
12345 Bob June 6
123324 joe June 5
12345 Bob June 5
243123 Smith June 5.5
I succesfully made a macro for this which creates a pivot table named Sheet1
The pivot table looks like this
Pers.No Sum of Hours
12345 11
123324 5
etc etc
Notice how this takes the total sum, even though there are duplicates with the same name and Id in the original sheet.
Now there is one more file called Company It currenly has
Employee no. Level Organization code Manager organization code etc
I automatically get this excel file.
What I want to do is take the PIVOT TABLE Sheet One, and make two more columns in middle or at the end of the new Company File it doesent matter say
Employee no. Level Organization code Pers.No Hours etc etc
These two added headers should simply take all the data from the pivot table ( as it is already sorted and in order, so this would be easier than reading from the original file called Cado)
Not sure if file 'Company' is a pivot or not. But, if not, then if both files contain the Employee No. you could simply use a vlookup to pull in the name and hours off of the pivot.

IF COUNTIFS() on filtered data

Question:
=IF((COUNTIFS(Data!F:F,35,Data!H:H,E2))<=0,"Future",(COUNTIFS(Data!F:F,35,Data!H:H,E2)))
The above doesn't work on filtered data. I've scowered the internet and failed to find a solution after hours of trying. I managed to find a solution for a single count on a different column:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(Data!G:G,ROW(Data!G:G)-MIN(ROW(Data!G:G)),,1)),ISNUMBER(SEARCH(A3,Data!G:G))+0)
I cannot figure out how to manipulate this in order to find the count of rows with both values of 35 and E2. Any ideas?
Back story:
I have a system which is used for a service desk. This has tickets on it which have recorded data on them.
Worksheet 1 (Data):
I have exported this data into a spreadsheet to create trend charts on. The data collected is:
ID, Tag, Department, Month Created, Month Resolved, Week Created and Week Resolved.
I have then created another column which works out the difference in weeks (i.e. how many weeks it takes to resolve a ticket) and applied a filter to these columns.
Worksheet 2 (Count Data):
I have a table that counts the Amount of tickets created and resolved each week. Also I have another table that counts how many were resolved by how many weeks it took to be resolved, for example there are 235 tickets, that were created in week 35 and took less then 1 week to be resolved.
Worksheet 3 (Charts):
I have two charts that show the resolution/creation trends over the weeks and the counts of each week by how long the tickets took to resolve.
Problem:
Quite a simple spreadsheet however when I filter the Data's department to only show specific departments the charts remain unchanged. It turns out this is because the COUNTIF and COUNTIFS functions count regardless of filters. How do I get around the COUNTIFS issue?
=IF((SUMPRODUCT(SUBTOTAL(3,OFFSET(Data!H2,ROW(Data!H:H)-ROW(Data!H2),)),(Data!F:‌​F=35)*(Data!H:H=E3)))<=0,"Future",(SUMPRODUCT(SUBTOTAL(3,OFFSET(Data!H2,ROW(Data!‌​H:H)-ROW(Data!H2),)),(Data!F:F=35)*(Data!H:H=E3))))
This is how I solved the issue.

Resources