Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have data like below. First column has combination of tags and numbers and second column has values
e.g.
First row: AB value is 10
Second row: Out of the value 20, AB is 10% & PQ is 90%
As these tags are custom defined for classification, the letter & numbers can be assumed to follow 2 characters each, except if the percentage is 100% there won't be any numbers after the letters (e.g. first row - AB)
If we segregate the tags and their values, it will be like below
I guess, an enhanced/customized SUMIF function is required to achieve this. Hope someone can give some ideas
What was tried so far:
I tried to do the steps in multiple steps, breaking down the tag into columns --> I was successful, but could not figure out how I can multiply the factor and get a summation. This way of doing it makes it hard to port the formula to other worksheets. Need to create additional columns etc. Hence abandon that plan
Thought of creating a VBA script to enhance the SUMIF function. Buy doing this I can copy the VBA code to other sheets and use my custom function. If needed the function can be enhanced further. To get some ideas on this plan, I posted this question
Thanks
I'm going to do this in two steps to make it easier to understand. First step: separate out the percentage factor by each keyword. Set up a table to the right of your data.
In the first row are all the codes you want to create sums for. Underneath it are the various desired percentages for each of your data rows. We're going to look for what's in row 1 inside what's in column A. If we don't find it then the element percentage is zero, if we find it but there's no number after, then the percentage is 100, otherwise use the 2 digit number that follows. Here's the formula in E2:
=IF(ISERROR(FIND(E$1,$A2)),0,IFERROR(VALUE(MID($A2,FIND(E$1,$A2)+LEN(E$1),2)),100))
The first part says if you don't find E$1 inside $A2 use a zero factor. The rest says to pick up the two digit number after the point you found E$1, but if it fails, use 100.
After copying the formula into all the cells, you can see the above factors. The rest is pretty easy. Incorporate the above formula into a sum range, multiplying by the value in column B and dividing by 100.
={SUM(IF(ISERROR(FIND(E$1,$A3:$A7)),0,IFERROR(VALUE(MID($A3:$A7,FIND(E$1,$A3:$A7)+LEN(E$1),2)),100))*$B3:$B7/100)}
Don't forget to terminate this array formula with Ctrl-Shift-Enter. I got the following results:
Related
I've been toying with this problem for some time but no matter how hard I try, I can't wrap my head around the syntax of a command.
Screenshot of Spreadsheet:
First thing's first. The layout of this spreadsheet can't be changed in any way, making this problem a whole lot more difficult to solve. I've added a screenshot above of what the spreadsheet looks like at the moment. It is currently just a test-sheet as the master-sheet is having real data inputted into it.
So the first problem is searching the array "D:H" for the shot listed in the "I" column. For example, I want to count how many times "Vodka" appears in the array (D:H).
The second problem is I then want to sum each number contained in the cell below the criteria. Following the same example, given the criteria "Vodka" (I4), I want to be able to sum all of the cells under any cell containing the word "Vodka".
The third problem is then to multiply it by the "Amount Sold". Once again, following the same example, I would multiply it by the cells "C5" and "C9" as both of the cocktails have a shot of vodka in them.
The last problem really wraps it all up in a tight little bow. All of this will need to be adaptable to adding, removing and changing cocktails to this list, as well as the shots that are in them and the shots that are being searched.
Again, this is all test information as I don't feel as though I should be putting out anything involving my workplace.
Any help on this would be greatly appreciated.
Count amount of vodka in D:H
=COUNTIF(D4:H13, "Vodka")
Sum of all Vodka
=SUMIF(D5:H5,"Vodka", D4:H4)
Instead of Hard-coding "Vodka" in the cell you should use reference to the cells. This makes expanding the table easier
If you have the value the last multiplication is no problem.
I have two descending running totals, and I want to sum the last item in each running total.
I would like the total to be in a single cell, and the total in this instance to be £2500 + £4492.55. As the running total continues, I expect the total in this cell to update.
(Apple Numbers is similar to Excel, which is why I have used the Excel tag here).
This approach works only if the calculation is not below the column of values, but above it:
=INDEX(C:C,MATCH(99^99,C:C,1))+INDEX(C:C,MATCH(99^99,C:C,1)-1)
Edit
Microsoft Support pages for Index and Match. With the extraordinarily large number and the 1 as the last argument, Match will return the position of the last populated numeric cell. Index will then return the value of that cell. Repeat, but return the second last row, by subtracting a 1 from the Match result. Add the two results.
Edit two
Since you did not want to do what you first said you want to do, here is a formula for what you currently say you want to do. Assume the first list of numbers is in column C and the second list of numbers is in column G:
=INDEX(C:C,MATCH(99^99,C:C,1))+INDEX(C:C,MATCH(99^99,G:G,1))
Edit three
You've clarified in the comments that you're using Apple Numbers, not Microsoft Excel. Unfortunately the above formulae may not work in that system, and help for that probably is out of the scope for Stack Overflow.
I was overcomplicating things.
MIN(C:C) + MIN(G:G) yielded the result I was looking for.
This might be a bit difficult to explain, but below is the spreadsheet im using, for the totals highlighted in blue i want to create a formula that shows the difference between the two years but only up to the previous month. For example as we are currently in July, i want to show the difference in the two years from May-June.
Currently i am using the formula;
=SUM(K4:K5)-SUM(F4:F5)
Which works, but it means i will have to update it every time i add information in for the new months. Is there a formula i can use thats not overly complicated to get the same result, but it will update automatically when i add new information in.
You can use the =SUMIF() formula.
It will only perform the sum operation if certain conditions are met, so we can set it up to sum all entries in a certain range that are not empty.
Here is a good explanation of the function.
https://exceljet.net/formula/sum-if-not-blank
So for your case, you would write (in the sum cell)
=SUMIF(K4:K15,"<>",K4:K15) - SUMIF(K4:K15,"<>",F4:F15)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want help to create same kind of file with a table whose elements are intervals with a fixed size of 10. The intervals should start at 15001 and end with 20000. I have attached a sample image of the excel sheet below. Please help me and tell me a method of creating such file which involves minimum typing.
Please help me.
I have also attached a image table for reference
There are a couple of ways to do this. The simplest is to enter your starting number in cell A1. Then in Cell A2 enter
=($A$1+(ROW()-ROW($A$2))*10+(COLUMN()-COLUMN($A$2))*650)&" to "&($A$1+(ROW()-ROW($A$2))*10+(COLUMN()-COLUMN($A$2))*650)+9
Copy that down till is has the number you want shown, and then copy all the formulas from the A column to the right.
Size and format your cells to suit your needs.
IF you do not want to put 1501 in cell $A$1 then in the formula replace $A$1 with 1501.
$A$2 will need to be adjusted to the cell you are using for your top left corner.
Explination
=($A$1+(ROW()-ROW($A$2))*10+(COLUMN()-COLUMN($A$2))*650)
This part of the formula determines the first number. you will notice you see it repeated exactly twice. At the end of the second repetition +9 was added to it to get the second number.
($A$1+(ROW()-ROW($A$2))*10+(COLUMN()-COLUMN($A$2))*650)+9
Once you have the two numbers figured out we glue them together so to speak by place a little concatenation sequence in between:
&" to "&
The important part here was to leave a space on either side of the word "to" so that when the numbers were place on either side there would be a space as well.
So how did that ugly formula work out to be a number? Well first we needed a starting point which was the Value in $A$1. In this case also 1501. Then we look at the pattern for the first number going down. Every row it increases by 10. So that means 1501+(each row)*10. So we need a way to count each row. I chose to do this with:
row()-row($A$2)
Row() without an address in it tell you the number of the row you are currently in. $A$2 is the address of the top left corner of the table. So if that formula were in the top left corner it would return a value of 2-2 = 0, and for the next row down it would be 3-2 = 1. So now we have a nice little counter going down and that is how we wound up with:
=$A$1+(ROW()-ROW($A$2))*10
Now we need to take care of the portion of how to increase the first number as we go across the columns. Looking at the pattern it increase 650 for each column. So similar to are ROW() function there is a COLUMN() function. We apply the same concepts that we did for the row calculation and add it to the formula we already have:
=$A$1+(ROW()-ROW($A$2))*10+(COLUMN()-COLUMN($A$2)*650
now technically speaking if you are doing this with A1 being your top left corner you can simplify the equation, and hardcode in the initial number and calculate your starting numbers with:
=1501+(ROW()-1)*10+(COLUMN()-1)*650
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a spreadsheet with times of races I have completed.
I want to be able to show the fastest time for a certain distance.
Please see the spreadsheet here.
I have highlighted the box I would like the formula in.
I have only been able to find a SUMIF statement, which only selects times based on a distance of 6.25, or a basic MIN function to return the lowest overall. I cannot find how to group these two functions.
The formulas I have tried are in the file to download.
However, I have tried the following
=SUMIF(C3:C38, "=6.25", F3:F38) - This gets the sum as expected
=MIN(F3:F38) - This gets the minimum as expected
I really do not know how to combine the two statements, the SUMIF is to only way I have found to evaluate one cell, but retrieve data from another
Any help is appreciated.
Thanks.
An array function should do the trick. Suppose that:
(1) The distances are stored in range A1:A10.
(2) Your times for each distance are stored in range B1:B10.
(3) The cell that contains the distance you want to find your best time for is cell C1.
The formula would be:
=MIN(IF(C1 = A1:A10, B1:B10, ""))
What the above formula is doing is returning the set of values in range B1:B10 for which A1:A10 = C1 evaluates to true. Note that the ranges don't have to be adjacent to each other: I could, for instance, store the race times in range B2:B11 and the distances in range X5:X14. The only thing that's important here is that the dimensions of each range are identical (in this case, both have ten rows and one column).
Make sure you hit Ctrl + Shift + Enter after the formula's entered into a cell, so that Excel recognizes it's an array formula. If you don't, it'll try to evaluate the expression as a normal formula, and return a #VALUE! error.