This is not high level Math, but I am struggling to apportion the appropriate amounts to my upsell types.
Type Revenue Sales Units
1st Position 24 3 3
2nd Position1 10 2
2nd Position2 5 1
Only my 1st positions count toward the return per sale values and they include the revenue of my 2nd positions that were generated from that sale.
IMPORTANT NOTE: If the return per sale value is greater than or equal to 12 I must apply a split for the amount over 12. My less than 12 value is *0.6 of the revenue, my greater than 12 value is *0.6 of amount less than 12 and *0.4 of amount over.
IF TotalRev/1st Position Units < 12 THEN TotalRev*.6 ELSE 7.2+(((TotalRev)/1stPositionUnits)-12)*.4)*1stPositionUnits = Total Revenue To Company.
IF (24+10+5)/3 < 12
THEN (24+10+5)*.6
ELSE ((.6*12)+((((24+10+5)/3)-12)*.4))*3
Net Revenue = 22.8
Net Return Per Sale = (Net Revenue/1st Position Units) = (22.8/3) = 7.6
Now I want to determine how much of the 1st position revenue contributed to the 7.6, how much of the 2nd position1 revenue and how much of the 3rd position...
My Attempt:
(1st Position Revenue/Total Revenue)*Net Return Per sale = (24/(24+10+5))*7.6 = 4.68
(2nd Position1 Revenue/Total Revenue)*Net Return Per sale = (10/(24+10+5))*7.6 = 1.95
(2nd Position2 Revenue/Total Revenue)*Net Return Per sale = (5/(24+10+5))*7.6 = 0.97
Double Check = (4.68+1.95+0.97) = 7.6
As your question, I guess this should be OK in your case.
Assuming the variables are defined with the same name as they are in the question(e.g., rev_1st_pos,rev_2nd_pos1,rev_2nd_pos2,new_rev_1st_pos,new_rev_2nd_pos1,new_rev_2nd_pos2,net_rev,net_return_per_sale,unit_1st_pos)...
The usual meanings for all the variables are :-
rev_1st_pos=Revenue of 1st Position
rev_2nd_pos1=Revenue of 2nd Position1
rev_2nd_pos2=Revenue of 2nd Position2
new_rev_1st_pos=New Revenue of 1st Position after total calculation
new_rev_2nd_pos1=New Revenue of 2nd Position1 after total calculation
new_rev_2nd_pos2=New Revenue of 2nd Position2 after total calculation
unit_1st_pos=1st position Units
net_rev=Net Revenue calculated as shown below
net_return_per_sale=Net Return per sale as calculated below
check= a variable used to check final value equals the net_return_per_sale.
Code :-
total_rev=(rev_1st_pos+rev_2nd_pos1+rev_2nd_pos2);
if((total_rev/unit_1st_pos)>=12)
{
net_rev=((((total_rev/unit_1st_pos)-12)*0.4)+(12*0.6))*unit_1st_pos; // OR simply substitute (12*0.6) by 7.2
}
else
{
net_rev=total_rev*0.6;
}
net_return_per_sale=net_rev/unit_1st_pos;
new_rev_1st_pos=(rev_1st_pos/total_rev)*net_return_per_sale;
new_rev_2nd_pos1=(rev_2nd_pos1/total_rev)*net_return_per_sale;
new_rev_2nd_pos2=(rev_2nd_pos2/total_rev)*net_return_per_sale;
double check=new_rev_1st_pos+new_rev_2nd_pos1+new_rev_2nd_pos2; // here check must be equal to net_return_per_sale
If there is still some issue,please leave a comment!
Related
I have a sample value as shown below
$item_A = $ 112.50 # 6% tax after tax = 9.25
$item_B = $ 10.00 # 0% tax
//I bought 2 item_A ($ 238.50) and 1 item_B ($ 10)
$sub_total = $ 235.00
$tax_amt = $ 13.50
$total = $ 248.50
At here i want to apply a discount $40 and then share among on the items price, which mean my total should be $208.75 after discounted.
discount will be based on setting either applied before or after tax of total amount
// formula to share among
$distribute = sub-total of item / total amount * discount
After get the $distribute, then will divide the quantity and add to the current unit price.
In this case, if i am recalculating the total amount, it will became lesser due to the unit price of item applied the discount.
My expected result is when applied $40 discount on $248.50, it will became $208.50 with a $40 discount applied even recalculate it.
is it need to remain the tax amount of the original price?
What is the solution to use to deal with this situation? Anyone can help and give suggestion on this case? Thanks.
I feel really confused trying to make it correct, but I'm not sure what is the right method to resolve this.
Eg : I have 5 students with their exam mark respectively
average : (1 + 2 + 3 + 4 + 5) / 5 = 3.00
So now, I want to add 5 to the average
new average : 3.00 + 5 = 8.00
Question: How to adjust students mark depending on the value added to the average?
If you want equal distribution among students, add the cumulative increased sum 25(number of students(5)*increased value) in respective ratio to total marks of each student.
i.e.
For first student add (1/15)*25 to his marks
For second student add (2/15)*25 to his marks
For third student add (3/15)*25 to his marks and so on
I have 3 nodes created in graph database, origin airport and destination airport and carrier. They are related by a property named 'canceled_by'.
MATCH (origin:origin_airport {name: row.ORIGIN}),
(destination:dest_airport {name: row.DEST}),
(carrier:Carrier {name: row.UNIQUE_CARRIER})
CREATE (origin)-[:cancelled_by {cancellation: row.count}]->(carrier)
CREATE (origin)-[:cancelled_by {cancellation: row.count}]->(destination)
CREATE (origin)-[:operated_by {carrier: row.UNIQUE_CARRIER}]->(carrier)
cancelled_by holds the value number of times particular carrier is cancelled. My input file will be of below format:
ORIGIN UNIQUE_CARRIER DEST Cancelled
ABE DL ATL 1
ABE EV ATL 1
ABE EV DTW 3
ABE EV ORD 3
ABQ DL DFW 2
ABQ B6 JFK 2
Here I need to calculate the cancellation percentage of each carrier. I am expecting result as below:
UNIQUE_CARRIER DEST Percentage_Cancelled
DL 25%
EV 58.33%
B6 16.66%
Example: Total number of cancellation = 12
No of cancellation for DL = 3
Percentage of cancellation for DL = (3/12)*100 = 25%
Below query gives the sum of cancellation for each carrier:
MATCH ()-[ca:cancelled_by]->(c:Carrier)
RETURN c.name AS Carrier,
SUM(toFloat(ca.cancellation)) As sum
ORDER BY sum DESC
LIMIT 10
I tried the below query for calculating percentage:
MATCH ()-[ca:cancelled_by]->(c:Carrier)
WITH SUM(toFloat(ca.cancellation)) As total
MATCH ()-[ca:cancelled_by]->(c:Carrier)
RETURN c.name AS Carrier,
(toFloat(ca.cancellation)/total)*100 AS percent
ORDER BY percent DESC
LIMIT 10
But it is not calculating percentage by grouping and instead calculating the percentage individually.
Carrier sum
DL 0.36862408915559364
DL 0.34290612944706383
DL 0.3171881697385341
How to calculate percentage based on group_by using cypher queries in Neo4j?
You forgot the summation by every carrier when grouping, and not necessarily always use a cast to float - just when the last calculation multiplied by the floating-point number.
MATCH ()-[ca:cancelled_by]->(:Carrier)
WITH SUM(ca.cancellation) As total
MATCH ()-[ca:cancelled_by]->(c:Carrier)
RETURN c.name AS Carrier,
100.0 * SUM(ca.cancellation) / total AS percent
ORDER BY percent DESC
LIMIT 10
Hi You could try using the R dplyr package.
Use the chaining operation %>% along with the functions
group_by, summarize and transmute. The group_byand summarize
will give you the sum of cancelled within each group. Use the
transmute function to get relative frequencies.
listed below multiple salesmen values comes in single report and Single Procedure
==========Salesman1==== Months ===== Percentage
M1 25 25%
M2 30 30%
M3 45 45%
------- how to get the % value based on total of
Total 100
==========
Salesman2 === Months ==== Percentage
M1 12.5 25%
M2 15 30%
M3 22.5 45%
-------
Total 50
i Calling some Value based on the Procdeure and added on the crystal report based on Count . i need the percentage of the particular salesman on the on the percentage but my parameter value brings all the count of all the salesman i cannot take the percentage based on the parameter value . instead of changing my procedure is there anyway to get the percentage of the given group by value
MY store Procedure Parameter are Months and salesmen
thanks in advance
In crystal reports you can create a formula field. Once you open the Formula Editor there is an inbuilt function of "PercentageBySum" which you can use and then drop this field besides your month. It will give you percentage for all values based on group total
Ted Schlossmacher's free GetQuote extension for OpenOffice.org Calc allows users to access quotes for several types of symbols tracked by Yahoo! Finance. Specifically, the GETHISTORY() function returns a range of past and present quotes.
After installing the extension, try highlighting a 5-column range and then typing =GETHISTORY("PETR4.SA",1,TODAY()-1) (you might need to use semicolons instead of commas) and then pressing Ctrl+Shift+Return. That should provide you with date, open, high, low and close quotes for PETR4, the preferred stock of Brazilian oil giant Petrobras S.A.
My question is: how can I, in one cell, insert a formula that would return me the value of the 5th column of the above array?
This can be done with the INDEX function. You don't need to use ctrl+shift+enter for it to work as it does't return an array.
=INDEX(GETHISTORY("PETR4.SA",1,TODAY()-1),1,5)
The 2 end parameters are row,column, and are a 1-based index into the array.
More information about INDEX can be found on any Excel website, or in the LibreOffice Calc help at https://help.libreoffice.org/Calc/Spreadsheet_Functions#INDEX
Yesterday's closing price can be retrieved using a second argument, for example:
=GETQUOTE("TD.TO",21)
From the manual:
GETQUOTE can fetch 31 types of quotes. The types are numbered from 0 to 30. The function accepts these numbers as the second argument.
0 = Last traded price
1 = Change in price for the day
2 = Opening price of the day
3 = High price of the day
4 = Low price of the day
5 = Volume
6 = Average Daily Volume
7 = Ask Price
8 = Bid Price
9 = Book Value
10 = Dividend/Share
11 = Earnings/Share
12 = Earnings/Share Estimate Current Year
13 = Earnings/Share Estimate Next Year
14 = Earnings/Share Estimate Next Quarter
15 = 52-week low
16 = Change from 52-week low
17 = 52-week high
18 = Change from 52-week high
19 = 50-day Moving Average
20 = 200-day Moving Average
21 = Previous Close
22 = Price/Earning Ratio
23 = Dividend Yield
24 = Price/Sales
25 = Price/Book
26 = PEG Ratio
27 = Price/EPS Estimate Current Year
28 = Price/EPS Estimate Next Year
29 = Short Ratio
30 = 1-year Target Price
If you need only the latest price (which is the fifth field) I believe you can simply use:
=GETQUOTE("PETR4.SA")
I'm not certain this works to return the current price when markets are open, but it does return the last trade price when markets are closed.