I’m trying to create a report that has everyday of the month listed as a column and sums the transaction quantity for that day if transactions exist and enters a 0 in the column if no transactions exist for that day.
Example:
Day
1 2 3 … 28 29 30 31
Sales Rep.
John Doe. 5 0 0… 10 15 0 30
Any ideas how to make this work? I thought about extracting the day from the transaction date but I can’t figure out how to get the days without any transactions. I thought about using current date to extract day but then the formulas would change every day. Ugh!! Help me please!
You can do this with 31 formula fields.
To avoid overlapping months add a formula text column with a formula TO_CHAR({trandate}, 'YYYY-MM')
Create a saved search on sales orders that filters to the month of interest and includes sales rep, date, document number and amount (at least)
for each date you want to report on include a formula numberic column with a formula like case when TO_number(TO_CHAR({trandate}, 'DD')) = 14 then {amount} else 0 end. Give it a custom label of the day number (e.g. 14)
Set summary columns as follows:
Sales Rep - Group
Document Number - Count
Formula Text - Group
each Formula Numeric - Sum
That's all you need to do but the 31 formula columns are tedious so when I do this sort of thing I do the following to create a template of the saved search and then add and adjust the date range (e.g. add filters in the displayed filter region)
Open any scripted record. Usually just view a sales order. If the step below fails try in a sales order in Edit mode. You won't be saving or updating the order
Right click and select 'Inspect'. This opens the developer tools
Find the 'console'. You should see some clear space at the bottom.
Copy and paste the text below into the console and press your enter key.
If all went well the script will print a number
You can then take the search title (Daily Rep Sales in the example code) and paste it in the NS global search. If you run the search you'll see the last 30 days of sales totalled by rep. Add and update filters (e.g. for different date ranges or only for last month or only for this month etc) and then make the search public to share it (or share it with certain users etc)
require(['N/search'], search =>{
var dateCols = [];
for(var i = 1; i< 32; i++){
dateCols.push(search.createColumn({
name:'formulanumeric',
summary:search.Summary.SUM,
label:'Day '+ i,
formula: "case when TO_number(TO_CHAR({trandate}, 'DD')) = "+ i + " then {amount} else 0 end"
}));
}
const searchId = search.create({
type:'salesorder',
title:'Daily Rep Sales',
filters:[
['mainline', 'is', 'T'], 'AND',
['trandate', 'onorafter', 'daysago30']
],
columns:[
search.createColumn({name:'formulatext', formula:"TO_CHAR({trandate}, 'YYYY-MM')", summary:search.Summary.GROUP}),
search.createColumn({name:'salesrep', summary:search.Summary.GROUP}),
search.createColumn({name:'tranid', summary:search.Summary.COUNT}),
search.createColumn({name:'trandate'}),
search.createColumn({name:'amount'})
// whatever drill down fields you want without summary
].concat(dateCols)
}).save();
console.log(searchId);
})
I have a teacher gradebook that uses category weighting (and evaluation weighting within each category). The formula I use to calculate final grade is found in column E here:
https://docs.google.com/spreadsheets/d/1TMsuJWtc4C7tebZGVVyeA4qbmLCnGZRi55ZRJsI-jGE/edit?usp=sharing
What I would like to do is give teachers an option to reduce the total marks for any particular student for an evaluation.
Example:
Evaluation total marks is 10, student mark is 4 (40%)
Teacher decides to make the total marks for this student = 5.
Teacher would enter: 4 [5] where 4 is the student mark and [5] is the new total marks for the evaluation. New percentage is 80%
I have written the formula to calculate the new percentage without issue however I cannot figure out how to get the final grade for this student.
In the linked spreadsheet above, student 1 and student 2 should have the same final grade in column E.
How can I change my formula in column E (starting at E8) to include cases like 4 [5]?
I believe the simplest solution would be to rewrite your formula in column E to use the numbers from the percentage column to calculate the grade, instead of using the complicated string you will find in the marks column.
Example formula that you could use in E8:
=IFERROR(SUMPRODUCT(FILTER(N8:Y8,ISFORMULA(N8:Y8))*FILTER(N$4:Y$4,ISNUMBER(N$4:Y$4))) *100 / SUM(N$4:Y$4),"")
Well that was fun! Using the recommendation of #TomSharpe I came up with this that seems to work:
=IF(ISBLANK($C8),"",IFERROR((
Settings!$E$3*(IF(COUNTIF($N$5:$HD$5,Settings!$D$3)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$3,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$3,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$4*(IF(COUNTIF($N$5:$HD$5,Settings!$D$4)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$4,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$4,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$5*(IF(COUNTIF($N$5:$HD$5,Settings!$D$5)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$5,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$5,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$6*(IF(COUNTIF($N$5:$HD$5,Settings!$D$6)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$6,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$6,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$7*(IF(COUNTIF($N$5:$HD$5,Settings!$D$7)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$7,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$7,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$8*(IF(COUNTIF($N$5:$HD$5,Settings!$D$8)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$8,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$8,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$9*(IF(COUNTIF($N$5:$HD$5,Settings!$D$9)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$9,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$9,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$10*(IF(COUNTIF($N$5:$HD$5,Settings!$D$10)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$10,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$10,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$11*(IF(COUNTIF($N$5:$HD$5,Settings!$D$11)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$11,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$11,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
+
Settings!$E$12*(IF(COUNTIF($N$5:$HD$5,Settings!$D$12)=0,0,SUMPRODUCT($O8:$HE8,$N$5:$HD$5=Settings!$D$12,$N$4:$HD$4)*100/SUMIFS($N$4:$HD$4,$N$5:$HD$5,Settings!$D$12,$O8:$HE8,">=0",$N$3:$HD$3,">=0")))
)/(IF(COUNTIFS($N$5:$HE$5,Settings!$D$3,N8:HE8,"<>")>=1,Settings!$E$3,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$4,N8:HE8,"<>")>=1,Settings!$E$4,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$5,N8:HE8,"<>")>=1,Settings!$E$5,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$6,N8:HE8,"<>")>=1,Settings!$E$6,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$7,N8:HE8,"<>")>=1,Settings!$E$7,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$8,N8:HE8,"<>")>=1,Settings!$E$8,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$9,N8:HE8,"<>")>=1,Settings!$E$9,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$10,N8:HE8,"<>")>=1,Settings!$E$10,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$11,N8:HE8,"<>")>=1,Settings!$E$11,0)+IF(COUNTIFS($N$5:$HE$5,Settings!$D$12,N8:HE8,"<>"
)>=1,Settings!$E$12,0)),"No Grade"))
I have this table in Excel:
I am trying to get weighted sum depending on two conditions:
Whether it is Company 1 or Company 2 (shares quantity differ)
Whether column A (Company 1) and column B (Company 2) has 0 or 1 (multipliers differ)
Example:
Lets calculate weighted sum for row 2:
Sum = 2 (multiplier 1) * 50 (1 share price) * 3 (shares quantity for Company 1) +
+0.5 (multiplier 0) * 50 (1 share price) * 6 (shares quantity for Company 2) = 450
So, Sum for Row 2 = 450.
For now I am checking only for multipliers (1 or 0) using this code:
=COUNTIF(A2:B2,0)*$B$9*$B$8 + COUNTIF(A2:B2,1)*$B$9*$B$7
But it does not take into account the shares quantities for Company 1 or Company 2. I only multiply 1 share price with multipliers, but not with shares quantity).
How can I also check whether it is Company 1 or Company 2 in order to multiply by corresponding Shares quantity?
Upd:
Rasmus0607 gave a solution when there are only two companies:
=$B$9*$E$8*IF(A2=1;$B$7;$B$8)+$B$9*$E$9*IF(B2=1;$B$7;$B$8)
Tom Sharpe gave a more general solution (number of companies can be greater than 2)
I uploaded my Excel file to DropBox:
Excel file
I can offer a more general way of doing it with the benefit of hindsight that you can apply to more than two columns by altering the second CHOOSE statement:-
=SUM(CHOOSE(2-A2:B2,$B$7,$B$8)*CHOOSE(COLUMN(A:B),$E$8,$E$9))*$B$9
Unfortunately it's an array formula that you have to enter with CtrlShiftEnter. But it's a moot point whether or not it would be better just to use one of the other answers with some repetition and keep it simple.
You could also try this:-
=SUMPRODUCT(N(OFFSET($B$6,2-A2:B2,0)),N(OFFSET($E$7,COLUMN(A:B),0)))*$B$9
Here's how it would be for three companies
=SUM(CHOOSE(2-A2:C2,$B$7,$B$8)*CHOOSE(COLUMN(A:C),$F$8,$F$9,$F$10))*$B$9
(array formula) or
=SUMPRODUCT(N(OFFSET($B$6,2-A2:C2,0)),N(OFFSET($F$7,COLUMN(A:C),0)))*$B$9
=$B$9*$E$8*IF(A2=1;$B$7;$B$8)+$B$9*$E$9*IF(B2=1;$B$7;$B$8)
Since in the COUNTIF function, you don't know beforehand, which company column contains a 0, or a 1, I would suggest a longer, but more systematic solution using IF:
=$B$9*$E$8*IF(A2=1;2;0,5)+$B$9*$E$9*IF(B2=1;2;0,5)
This is a bit less general, but should produce the result you expect in this case.
I have a programming issue in Excel that I don't know how to solve it. I want to create an automatic Delivery Cost Program on Excel that will help me calculating the cost more easily.
The input variables are:
Quantity (Values for 1, 2-9,10-49,50+ and more)
Shipping method
Depending on the Quantity Value and Shipping method, Excel should lookup on the table and return the total shipping cost according the following Table:
------------------------------------------
Delivery | Per shipment fee
------------------------------------------
| 1 2-9 10-49 50+
------------------------------------------
Standard | 2,99 1,89 1,5 1,1
Expedited | 5,99 2 1,75 1,25
Priority | 10,99 3,39 2,25 1,35
------------------------------------------
Let me show you with some examples what I want to get:
1- Example:
- Quantity: 15
- Delivery: Expedited
- Total Cost = 15 * 1,75 = 26,25$
1,75$ is the returned value after looking on the table using the variable Quantity and Shipping Method.
I have tested doing =IF statements but sure that there is an easier way to do it.
I'm not very good on Excel programming so any help will be appreciated
Best regards and have a great day!
Assuming that your table has the delivery types in column A in rows 4 through 6 and that the quantities are in row 3 (columns B through E) the following formula should do it for you:
=INDEX(B4:E6,MATCH(B9,A4:A6,0),MATCH(C9,B3:E3,1)) * Quantity
Note, that the quantities in row 3 must be a number. So, the numbers should be 1, 2, 10, and 50 and not 1, 2-9, 10-59, 50+. There are two possibilities to achieve that:
Create a helper row and hide it (while only showing the row with the "names" as you wish for.
Change the number format on these cells: for the column containing the 2 the number format should then be "2-9" (custom number format). For the number 10 the number format would be "10-49" and the number format for the last column would be "50+". Like this you see what you wan to see while the cells still contain numbers only (for the upper formula to work correctly).
I have a retail store that sells items on consignment for a fee that varies based on Selling Price.
So my question is how do I write a formula that checks the selling price and then charges the correct consignment fee to calculate the net based on the following schedule:
When selling price is over $400 then charge = 20%
When Selling price is $100 to $400 then charge = 30%
When Selling price is under $100 then charge = 40%
BLUF: use nested IF statements (an IF inside an IF) --
Example:
=IF(A2>=400, (A2*0.2), (IF(400 > A2 >= 100, (A2 *0.3), (A2*0.4))))
Or use the below if you suspect someone will foolishly enter a negative number or something nonsensical:
=IF(A2>=400, (A2*0.2), (IF(400 > A2 >= 100, (A2 *0.3), (IF(A2 < 100, (A2*0.4), (0))))))
That may look complex, but let's break it down from the beginning.
The basic formula for the IF statement:
=IF(testCondition, (resultIfTrue), (resultIfFalse))
One IF statement will only allow you to do two of your 3 conditions:
=IF(A1 > 400, (A1 * .20), (A1 * .30))
The above basically says that if the number in cell A1 is greater than 400, then the value in your current cell (e.g. B2) is A1 * 20%. But if the number in A1 is NOT greater than 400, the value in your cell will be A1 * 30%.
But how do we calculate the range you were asking (i.e. 100 - 400) and how do we add in a third possibility (i.e. the possibility that the number is less than 100)?
The answer is to use a nested IF. You can tell the cell what it's value should be if the condition is true, but you can test another condition if the answer is false (i.e. the next IF statement stands in the place of resultIfFalse.
=IF(testCondition, (resultIfTrue), (IF(testCondition, (resultIfTrue), (resultIfFalse))))
The above can handle 3 different scenarios. Out of the IFs above, you could also replace the second IFs resultIfFalse with yet another IF statement, and so on. You can nest up to 64 IF statements.
Extra Resources:
http://fiveminutelessons.com/learn-microsoft-excel/using-multiple-if-statements-excel
http://spreadsheets.about.com/od/tipsandfaqs/qt/nested_if.htm
Nested IF functions are not user friendly and require hardcoding your variables (percentages). My suggestion would always be to have a small table of values elsewhere: eg. put the following in A1:B3
0 0.4
100 0.3
401 0.2
Assuming your data is in D1 you can use the following formula in E1 and drag down if necessary
=INDEX($B$1:$B$3,MATCH($D1,$A$1:$A$3,1))
This way you can change your boundaries/ add more conditions easily without more nested IF statements
Try using this instead:
=IF(B1<100,B1*40%,IF((B1>=100)*AND(B1<=400),B1*30%,IF(B1>100,B1*20%,"Invalid Price"))
This formula contains nested-ifs and a logical AND condition which will give the result.