google spreadsheets switch statement - switch-statement

I'm trying to calculate a daily salary in a google spreadsheet.
in this particular job the hourly wage depends on the total amount of daily sales.
here are the specifics:
Sales - Hourly
$0.00 - $8.00
$350.00 - $9.00
$400.00 - $10.00
$500.00 - $11.00
$600.00 - $12.00
$700.00 - $14.00
$800.00 - $16.00
$900.00 - $18.00
$1,000.00 - $20.00
$1,300.00 - $23.00
$1,600.00 - $26.00
$2,000.00 - $30.00
for instance : if the sales rep sells $545 he will get $11 per hour untill he breaks the $600 mark.
in another sheet the employees input their check in and check out time, and their daily sales.
i have extracted the daily work hours and i would like to implement a switch statement equivalent that will calculate the hourly wage depending on the daily sales.
and then simply multiply them and calculate the daily salary.
thanks in advance.

You want a VLOOKUP here. Off my mind, taking the sales column is A and hourly rate column is B and they have no headers (12 rows per value):
=VLOOKUP(400, $A$1:$B$12, 2, TRUE)
The 400 there would be the employee daily sales (you can change for a cell data).
More info about VLOOKUP here: https://support.google.com/docs/answer/3093318
PS: the first column needs to be sorted (that's the TRUE last argument) and be formatted as numeric (not as text), but I guess you already have that. If the list is not sorted, or is not numeric VLOOKUP only matches the exact search key

Related

Cash-flow forecasting in excel

I would like it to be able to input contract details (name of the client, duration of the contract and total yearly amount ). Using these contract details, I would like for the program or template to populate a calendar in which we can see each day's deposits.
For example: If I entered 2 contracts:
Total yearly amount of 120$ that start on 01/01/2019
Total yearly amount of 180$ that start on 01/03/2019
by choosing to view March calendar, I would see on the 01/03/2019 2 deposits one of 10$ and the other of 15$ for a total of 25$. But, If I choose to view the month of February, I would see on 01/02/2019 1 deposit of 10$.
I have started an excel sheet which populates it perfectly if it is one time deposit for a specific date.
Where I got stuck was for monthly deposits and special deposits (special conditions where the first month required 25% of the total yearly amount, and will complete the remainder 75% of the total yearly amount in 5 equal deposit the following months).
Here is my basic formula I have put on each day for the month of Janurary:
=IFERROR(IF(AND(VALUE(LEFT(Inputs!$D3,2))=B$2,(VALUE(MID(Inputs!$D3,4,2))='C.F. JAN'!$B$1)),IF(Inputs!$C3="Fixed Monthly",Inputs!$G3/12,IF(Inputs!$C3="Yearly",Inputs!$G3,"")),""),"")
Here is the one of Februrary:
=IFERROR(IF(AND(VALUE(LEFT(Inputs!$D3,2))=C$2,(VALUE(MID(Inputs!$D3,4,2))='C.F. FEB'!$B$1)),IF(Inputs!$C3="Fixed Monthly",Inputs!$G3/12,IF(Inputs!$C3="Yearly",Inputs!$G3,"")),""),"")
I have created sheets for each month that sum the amounts each client's appropriate deposit.
#jessi here is how my data looks like:
here is the formula on M3:
=SUMIF($D$3:$D$10000,$L3,$H$3:$H$10000)+SUMIFS($I$3:$I$10000,$D$3:$D$10000,"<"&$L3,$J$3:$J$10000,">="&$L3)
So, you can do some preliminary math so that your if statements are very simple.
Here's an example. see the added columns? You could enter the data for Contract, Value, Start, First, and Installments. Calculations for FirstPayment, NormalPayment, and Stop.
FirstPayment, for contract a, Row 2, calculated as:
=IF(ISBLANK(D2),G2,D2*B2)
NormalPayment for contract a, Row 2, calculated as:
=IF(ISBLANK(D2),B2/E2,(1-D2)*B2/E2)
Stop for contract a, Row 2 calculated as:
=IF(ISBLANK(D2),EDATE(C2,E2),EDATE(C2,E2+1))
Then, the months with their payments expected, look like so (the formula for January shown):
NOTE: the date 2019-01-01 is in A7, the result (where this formula goes) is in A8. Copy and paste for rest of columns.
=SUMIF($C$2:$C$4,$A7,$F$2:$F$4)+SUMIFS($G$2:G$4,$C$2:$C$4,"<"&$A7,$H$2:$H$4,">="&$A7)
Note that the first SUMIF is dealing with anything that is in its first month. The SUMIFs is dealing with anything that is between Start and Stop.
Edit for changed question to show cashflow by day
To show by day, you first need to add another column, let's say column I, to the data table for contracts. This is the DAY column. DAY($C2). To keep things simple for your cashflow, actually make this If(day($C2)>28),1,day($C2)) to make any falls on 29, 30, or 31 to show up on the next first. You can make other choices here.
Then, you can have each day in time in your cashflow sheet.
I put the cashflow on a new tab and named the contracts data tab CONTRACTS
The cashflow formula (with date in $A2 and result in $B2) is:
=SUMIF(CONTRACTS!$C$2:$C$5,$A2,CONTRACTS!$F$2:$F$5)+SUMIFS(CONTRACTS!$G$2:G$5,CONTRACTS!$C$2:$C$5,"<"&$A2,CONTRACTS!$H$2:$H$5,">="&$A2,CONTRACTS!$I$2:$I$5,DAY(A2))

Cannot find Price in Excel Document

I have a list of Stock prices that i have imported into Excel. I wanted to check if a given price would have potentially been reached within the range of the Open Price and the Close price of any given day.
For Example:
The Price I am looking for is 11.98
I Now want to know if within the last 100 trading days of data that I have...how many times the price of 11.98 could have appeared. With the idea that if the Open Price on a hypothetical day was 11.50 and the closing price of the same stock on that day was 12.23, then Hypothetically the price of 11.98 could have occurred). If price i am searching for (in my example, 11.98) could hypothetically have occurred in a day, I will count that as one occurrence...using my example of 100 trading days...then the maximum number of occurrences would be 100 (or once per day). I would like to do this in excel and would like help in what the formula should be. Ultimately, I would like a value representing how many times the price I am interested in has occured. THank you in advance.
Lets assume column A is your date, column B is your opening price, column C is your closing price and the price you are looking for is in D2.
=SUMPRODUCT((A2:A6>=TODAY()-100)*(B2:B6<=$D$2)*(C2:C6>=$D$2))+SUMPRODUCT((A2:A6>=TODAY()-100)*(B2:B6>=$D$2)*(C2:C6<=$D$2))
Now this will not cover case where the opening price and the closing price are both lower or both higher than a trading price occurring in the middle of the day.
NOTE: This assumes that the date in column A is stored in excel time date serial format and is not text. If it is text the formula will need to be adjusted.

Excel PowerPivot Average Calculation

I am having some difficulty determining how to produce a calculation of averages that can be plotted on a PivotChart.
Specifically, I wish to compare a Sales Rep's performance (gross profit by month/year) against all other reps (using an average) who are in a comparable role (the same workgroup) for a given period.
Let's just say the data structure is as follows:
SaleID SaleLocation SaleType SalesRep SaleDate WorkGroup SalesGP
1 Retail1 Car John A 01/01/2014 Sales $301
2 HQ Bike John A 01/01/2014 Sales $200
3 Retail1 Car Sam L 02/01/2014 Sales $1300
4 Retail2 Plane Sam L 02/01/2014 Sales $72
5 Retail2 Plane Vince T 03/01/2014 Admin $55
6 Retail2 Bike John A 04/01/2014 Sales $39
7 HQ Car Vince T 05/01/2014 Admin $2154
....etc
In the excel data model I've added calculated fields (that use a lookup table) for the sale date so that sales can be plotted by Month or Year (eg. =YEAR([SaleDate]) and =MONTH([SaleDate]))
As an example, let's say I want to plot someone's GP (Gross Profit) for a period of time:
My question is this......
How can I calculate an "average gross profit" that I can plot on the PivotChart? This "average gross profit" should be the average of all sales for the same period for the same workgroup.
In the example above, in the PivotChart I am wanting to plot an "average" series which plots the average GP by month for all SalesReps that are in the same Workgroup as John A ("Sales").
If my request isn't clear enough please let me know and I'll do my best to expand.
Zam, this should be quite easy. You just need to create a new calculated field that calculates the average for ALL sales rep.
Let me walk you through it:
I used your data table and then added it to my PowerPivot (Excel 2013). Then I created those calculated measures:
1. Sales Average:
=AVERAGE(SalesData[SalesGP])
2. Sales Average ALL -- this will calculate the average for ALL rows in the table and will be used in other calculations. Notice I used the first calculated field as the first parameter to make this flexible:
=CALCULATE([Sales Amount Average],ALL(SalesData))
3. Sales Comparison to Average. I wasn't sure what is your goal, but I made this one a bit more complex as I wanted to display the performance in percentage:
=IF([Sales Amount Average] > 0, [Sales Amount Average] / [Sales Average ALL] -1)
Basically, what this does is that first it checks if their an existing calculation for a sales representative, if so then it divides Sales Average for a given sales representative by the average sale amount for ALL sales representatives. And then I subtract 1 so the performance can be easily grasped just by looking at the percentages.
To make it easy-to-understand, I decided to use bar charts in conditional formatting instead of stand-alone pivotchart -- I believe it does exactly what you need:
In the picture above, the first table represents your data. The second table is the actual powerpivot table and shows what I have described.
Hope this helps!
EDIT
I didn't want to make things over-complicated, but should you want to remove the percentage total from Grand Totals row, use this calculation instead for the percentage comparison:
=IF(HASONEVALUE(SalesData[SalesRep]),
IF([Sales Amount Average] > 0,
[Sales Amount Average] / [Sales Average ALL] -1),
BLANK()
)
EDIT - ADDED AVERAGE COMPARISON FOR WORKGROUPS
To calculate the performance per workgroup instead of ALL sales representative, add those two measures:
4. Sales Average per Workgroup
=CALCULATE(AVERAGE(SalesData[SalesGP]),ALL(SalesData[SalesRep]))
This will calculate the average sale per workgroup (don't get confused with using SalesRep in ALL function, it's related to filter context).
5. Sales Diff to Average per Workgroup
=IF(HASONEVALUE(SalesData[SalesRep]),IF([Sales Amount Average] > 0, [Sales Amount Average] - [Sales Average per Workgroup]),BLANK())
This simply calculates the difference between average sale of given sales rep and the average sale per workgroup. The result could then look like this:
I have uploaded the source file to my public Dropbox folder.

Calculate the average sale for each month in excel 2013 pivot table

I have a large chunk of sales data with (some columns removed for clarity purposes):
Order Id, Order Date, Product, Amount, Product Price, Row total cost, Order total cost
A specific order can, as you may see, be divided over multiple rows - were order id, order date and order total is the same on each row. The "row total cost" contains the price for a specific amount of a specific product in the order.
It's not the best way to store data - I know...
Any ways. What I would like to do is to calculate the average sales value for each month. For example - total sales in sep 2012 is $1000, and in sep 2013 it's $500. The average sale for september would be 1000 + 500 / 2 = $750.
This I would like to present in a pivot table and pivot chart.
What I'm stuck with is an average sales value compared to the grand total (sep 2013 compared with all month of 2013 and 2012). I believe I need to group or filter my average calculation - but can't figure out how to do that.
Any help is much appreciated. Using Excel 2013.
Is the challenge caused by the "Order Total Cost" column containing repeats, and hence when you get average of that column it is not accurate?
If I assume that the columns you list are headings in row 1 and that data starts in row 2, then add a column headed Real order total with the formula =if(A2=A1,"",G2) in cell H2. Copy that down and it will give the order total just once for each order. Then base your average or pivot table on col H rather than G.

Difference Between Quota and Sales Count in Pivot table

This is driving me nuts.
I have a table of sales information based on dates as followed.
Date Price
1/1/12 5
2/1/12 5
12/1/12 5
Now i've used a pivot table firstly to group by week, then count the number of values for sales and tally up the Price as followed
Week Quantity Revenue
1/1/12 - 7/1/12 2 10
8/1/12 - 15/1/12 1 5
I have a 'quota' or desired quantity per week which is 3 and i'd like another column that subtracts 3 from the quantity to give me a difference like so.
Week Quantity Revenue Difference
1/1/12 - 7/1/12 2 10 -1
8/1/12 - 15/1/12 1 5 -2
I've tried adding a formula to do this but firstly i can't access the quantity column because its not a field and i can't work out the formula to make a field to replace the quantity column. Any ideas?
The only way I can figure to do it is to change the source data and add Quota and Quantity columns to it. The quota has to be calculated so that it adds up to the desired amount per week, in this case 3.
The formula for the quota calculation is:
=($F$2/7)/COUNTIF($A$2:$A$22,A2)
You can then make a calculated field, here shown as "Sum of Field 1":
This isn't a very manageable solution. And if you have multiple products and/or different quotas it will get uglier fast! But it's the best way I can see to do it with a pivot table.

Resources