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

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:

Related

excel PowerPivot Auto Calculated Measures & Columns

After looking at a few similarish questions I figured I needed something more specific so asking here. I will start by explaining the situation:
The Setup
I have a Store which sells Cakes, Cookies and Wine. I have the weekly sales data of each product sorta like this:
Product ID
Product Name
Quantity
Value
Week Ending
1
Ginderbread
2
£4
13/01/22
2
Chocolate chip
5
£25
13/01/22
3
Red Wine Bottle
1
£10
13/01/22
4
Sponge Cake
3
£9
13/01/22
Currently every week's data is stored within the same table, with me using a Week filter to show only the week i'm interested in.
Using this Data I created PivotTables that shows the sales of each category, with the ability to drill down to show the specific products. Table looks something like this:
Category
Quantity
Value
Cakes
2
£4
Cookies
7
£29
Wine
1
£10
The issue
I now want to stick in a new calculated column that shows the Value as a %. E.g The total value for the previous table was £43, so Cookies is about 67%. If I drill down, it would show the Chocolate Chip record as 80% and Gingerbread as 20%
I imagine doing this would be easier if each individual week's data was on a different table, but I got a lot of weeks and I also want to do tables showing the sales for over a period of time. Plus I don't know of a way to merge the "value" and "quantity" columns, etc instead of having 1 for each week being shown.
any advice would be appreciated
Create an extra column in the source table (prior to filtering) entitled "perc" calculated as the corresponding value for each row divdied by the total value across all rows (se pic. / eqn. for first row below) --
=E2/$E$6
No calculated fields required - just include perc as the mesaure of interest in your pivot table, with value setting as 'sum':
The reason why this worked is because of the common denominator - which allows one to sum ratios on a 1:1 basis.
Devising a calculated field using the standard 'fields, items & sets' functionality for ordinary pivot tables would not be feasible / possible as far as I am aware. You would need to move into the realm of power pivots and data models - which is not too complicated (readily accesible directly from the field list per below) - however, I see this as unnecessary complication for the task at hand.
Side notes:
Using table names in your functions is sometimes more convenient when entering, albeit may appear tricky at first when reviewing - first eqn above becomes:
=[#Value]/Table1[[#Totals],[Value]]

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

Excel PowerPivot DAX Calculated Field

I think I've got a relatively easy problem here on my hands, just having trouble getting it to work. Let me preface this by saying I'm new to DAX.
Consider the following PowerPivot Data Model :
It consists of a Sales Records table, which is joined to a Date lookup table, as well as a "Daily Expenses" table. The "Daily Expenses" table stores a single value which represents the averaged cost of running a specific trading location per day.
It's extremely easy to produce a PivotTable that provides me with the total Sales Amount per store per [insert date period]. What I'm after is a DAX formulation that will calculate the profit per store per day - ie. Total Sales minus DailyExpenses (operating cost):
In theory, this should be pretty easy, but I'm confused about how to utilise DAX row context.
Failed attempts:
Profit:=CALCULATE(SUM(SalesInformation[SaleAmount] - DailyStoreExpenses[DailyExpense]))
Profit:=CALCULATE(SUM(SalesInformation[SaleAmount] - DailyStoreExpenses[DailyExpense]), DailyStoreExpenses[StoreLocation])
Profit:=SUM(SalesInformation[SaleAmount] - RELATED(DailyStoreExpenses[DailyExpense])
etc
Any help appreciated.
Zam, unfortunately your failed attempts are not close :-)
The answer, and best practice, is use a 4th table called 'Stores' which contains a unique record per store - not only is this useful for bringing together data from your two fact tables but it can contain additional info about the stores which you can use for alternative aggregations e.g. Format, Location etc.
You should create a relationship between each of the Sales and Expenses tables and the Store table and then use measures like:
[Sales] = SUM(SalesInformation[SaleAmount])
[Expenses] = SUM(DailyStoreExpenses[DailyExpense])
[Profit] = [Sales] - [Expenses]
Provided you have the Date and Store tables correctly linked to the two 'Fact' tables (ie Sales and Expenses) then the whole thing should line up nicely.
Edit:
If you want to roll this up into weeks, years etc. and you have no kind of relationship between expenses and the calendar then you'll need to adjust your expenses measure accordingly:
[Expenses] = SUM(DailyStoreExpenses[DailyExpense]) * COUNTROWS(DateTable)
This will basically take the number of days in that particular filter context and multiply the expenses by it.

query in a powerpivot table to do a group by

I have a table called "purchase" with the following data:
year month time day_week name provider service purchase revenue
I am using this data to make a pivot table. Then I have another table called "active":
name provider service description month year number_active
I used this data to create a separate pivot table.
Now I need a third pivot table with something like:
number_active/revenue
and slice it vertically to by year. The problem is that I cannot create a relationship between the table because in Purchase I have the services by day and hour and in Active I have the services by month. I think I need to create another table that is a view of Purchase grouped by month.
I tried the following :
home -> From Database -> From analysis services or PowerPivot
But i have a error:
I'm not sure where to go from here.
How can I make this view grouped by month?
I don't think you need to create a new view of summarized data as a source. You just need to be able to summarize by date, and you can do this by adding a date dimension.
You can download one for free from the Windows Azure marketplace.
Once you have your date table, add a calculated column to the Active table in your Power Pivot model called Date that is =[Month]&"/01/"&[year]. Then change the data type to date.
Then do the same thing to your Purchase table. Next, create relationships from Active[Date] to Date[DateKey] and from Purchase[Date] to Date[DateKey].
You could make all of this go down to the time level and related it there instead (Power Pivot will assume midnight if you don't specify a time in your date column). But I'm simplifying since that is not needed for this one scenario.
Next make your two base calculated measures
Number Active:=Sum(Active[number_active])
Total Revenue:=Sum(Purchase[revenue])
I'm not sure what your number active means, so I'm assuming it is just a sum. You can adjust this calc if this is not the case.
Then make your final calculation: Revenue Per Active User:= [Number Active]/[Total Revenue]
Then you should be able to pull month and year into a pivot table along with this new calculated measure and your original measures (number active and revenue).

Using a Pivot Table to run Overtime Analysis

I am working on an overtime analysis report in which the data has been imported into Excel (2010). I need to show overtime and time off hours only. I've grouped all the time off hours by creating an additional column that only contains those hours (three different codes). Once the pivot tables are created, I'm creating line charts to show any correlation between time off and overtime in a department, month, and by person. It's working great for most of the employees, but . . .
The issue I'm having is that a segment of our employees have overtime built into their schedule, so the OT column values need to be reduced by that number. (YTD built-in hours is 42).
I've created a calculated field to give me the adjusted OT hours. The problem is when I create the chart, it includes all the fields - the time off data, the total overtime, and the adjusted overtime. If I filter out the overtime, the table doesn't do the calculations for the adjusted overtime. Is there a way to keep just the time off and adjusted overtime hours?
Calculations on detail records should not be done in a Pivot table. If - in your detail table - you create (or have) a field EmpClass that leads to another parameter table specifying the working hours per class, you can - via VLOOKUP and other functions - calculate the correct work/free/overtime for each record in the detail table and aggregate only these result fields.

Resources