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.
Related
I am trying to count groupings of elements in a list, in Excel, with groupings defined by 2 conditions: same Element and same Group code, as shown in the image below. The column C formula seems to throw errors as shown in orange highlighting in cells C9-C11. The formula for column C is displayed starting in column D. My expected grouping count is shown in column L with explanation starting in column M. Cells L9-L12 show what I expect the element count to be for Element X/Group 0.
Is there a correct formula for counting multiple-criteria groupings in Excel 365? I have tried various iterations of countifs() and sumproduct (See column D of the screencap) with no luck yet.
Post possible solution:
Now showing a scenario where the solution doesn't hold up (holds up in all other 16 scenarios I ran but not this one ???), see the orange cells with strange output versus expected output in yellow:
OK well in the first iteration of your question what seemed like a long time ago we all assumed that you wanted to count the total number of unique groups you have got so far. Now it's looking a bit different - the example implies that if both the element and group are repeated later on you want to revert back to the count of that element and group only and not the total count. I think what you want is a match like this:
=MATCH(A4&B4,SORT(UNIQUE(FILTER(A$4:A4&B$4:B4,A$4:A4<>""))),0)-
MATCH(A4&"*",SORT(UNIQUE(FILTER(A$4:A4&B$4:B4,A$4:A4<>""))),0)+1
Could be simplified using Let but it's late here and it's tentative anyway.
However the sorting assumes that the group keeps on increasing within each element and that wasn't the case in the first iteration of your question. You could try Sortby just sorting on the Element but that will have to wait till tomorrow.
EDIT
Here is my revised formula - plz try it.
=LET(range,A4:B$4,
unique,UNIQUE(range),
uniqueElement,INDEX(unique,0,1),
sortby,SORTBY(unique,uniqueElement,1),
sortElement,INDEX(sortby,0,1),
sortGroup,INDEX(sortby,0,2),
MATCH(1,(sortElement=A4)*(sortGroup=B4),0)
-MATCH(A4,sortElement,0)+1)
You could also use Take instead of Index. I've removed the filter for clarity because there aren't any blanks in the test data.
I'm creating a personnel tracker, I'd like to "double check" that I have the people I need on a given day. With people as rows, and dates as the columns, I want to check the column for a particular day to see if I have coverage at a glance.
=IF(SUMPRODUCT(COUNTIFS(BR4:BR46,{"Mc";"Ec";"M";"F";"Fe";"W";"Fe";"Ca";"Ce"}))>=7,"T","F")
This seems to work, but after some experimentation it is counting other strings in the column (so W or F might match on WF) which isn't what I want.
COUNTIFS works differently when you use an array as the criteria. It outputs an array the size of criteria showing have many matches were made for each item in criteria. Instead of using SUMPRODUCT, you need to count the number of values above 0. I've solved it by forcing every value of 0 in the array to be an error, and counting all non-errors.
=IF(COUNT(COUNTIFS(BR4:BR46,{"Mc";"Ec";"M";"F";"Fe";"W";"Fe";"Ca";"Ce"})^0)>=7,"T","F")
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:
I am new to Stackoverflow, so please let me know me if there is not enough information. I have had many helpfull insights by using StackOverflow in the past, but I cannot find any helpful thread online, so I hope you can help me.
I've been working on a excel (2013) problem for a while now. I am trying to build a marketing agenda to store and keep track of our mailing campaigns. The campaigns themselves are send via another system, but we miss the ability to plan our mailing campaigns in advance. Since we are active on different markets in Europe, we decided to have a general mailing (for all regions) and a region specific mailing campaign (both are in the same agenda). Besides this we also want to display the mailing focus (different brands). It is my idea to return this as visual as possible (to make it usable for all users). I have add a small picture to show my desired end-result (however without any data at this moment).
At this moment, the users are going to use a (Google)form to enter the campaign information and this data is downloaded to the worksheet (by doing so all users can add new campaigns and everyone always has access to the most recent data). This part works well.
I am using a helper sheet to check if the dates fall in a campaign range, if it does fall in a campaign range it should return the mailing ID (also the row number). I have another form which uses this data to search for the right brand and displays visually (with a lot of conditional formatting).
The problem arises in the helper sheet (when I check if a date fall into a campaign range). I have been able to get it working (more or less) with the following formula:
=IF(SUMPRODUCT(--(CountryHelper!$C$2:$C$100<=$B4);--(CountryHelper!$D$2:$D$100>=$B4);RIJ(CountryHelper!$C$2:$C$100))=0;"";INDEX(CountryHelper!$A$2:$A$100;SOMPRODUCT(--(CountryHelper!$C$2:$C$100<=$B4);--(CountryHelper!$D$2:$D$100>=$B4);ROW(CountryHelper!$A$2:$A$100))))
In this formula, CountryHelper!C:C is referencing the StartDate of the mailing campaing. D:D will reference the column of the EndDates and A:A has the mailing ID. Cell B4 is the date that needs to be checked.
At first it looked this worked perfectly. If a date fell in a date range then it would return the ID. After a little playing around with this a problem came to light. It only works with non overlapping dates, once dates overlap excel will add the row numbers together and it would not work any more.
Is it possible to get the sumproduct formula working and returning only the first ID. I am aware that I then have to make another 2 formulas which return the second and third ID ( I am certain we do not get more than 3 overlapping dates). This is also the part where I get lost. I've tried to use a MIN and MAX variation wit the following sumproduct formula:
=SUMPRODUCT(--(CountryHelper!$C$2:$C$100<=$B4);--(CountryHelper_RSEU!$D$1:$D$100>=$B4);ROW(CountryHelper!$C$1:$C$100))
This will return either a 0 (with MIN) or 100 (With MAX). I think this is caused by the formula (for now it only searches the first 99 rows). I also have ventured into VBA / UDF to get this done, but as I understand it this is not possible.
Anyway, I am sorry for the long story, I hope that my problem is clear and you can help me. If you need any more information.
Thank you!
empty Marketing Agenda overview
The SUMPRODUCT is a kind of swiss army knife Excel function. But here it is wrong because, as you already have seen, it really calculates a SUM at the end. Mostly it works because it first multiplies the 0 or 1 of the conditions with the row numbers so only the row numbers which fulfills the conditions comes into the sum. But if two or more row numbers fulfil the conditions then they were added together.
Are you familiar with array formulas? The following array formula should be what you want:
{=INDEX(CountryHelper!$A$2:$A$100;MIN(IF((CountryHelper!$C$2:$C$100<=$B4)*(CountryHelper!$D$2:$D$100>=$B4);ROW(CountryHelper!$A$2:$A$100)-1)))}
To create a array formula put the formula into the cell without the curly brackets and then press [Ctrl]+[Shift]+[Enter]. Then the curly brackets should appear automaticaly.
How it works:
{IF((CountryHelper!$C$2:$C$100<=$B4)*(CountryHelper!$D$2:$D$100>=$B4);ROW(CountryHelper!$A$2:$A$100)-1)}
Gets a array of row numbers or FALSE {FALSE, rowNumber, FALSE, ...}. If both conditions are fulfilled then it gets the row number - 1, if not then it gets FALSE.
The MIN function then gets the smallest (row number - 1) from this array.
The INDEX then indicates this smallest (row number - 1) which fulfills the conditions.
It subtracts 1 from the row number because your INDEX range starts at row 2. If the row number 2 fulfills the conditions then it is the index 1 within this range, if row number 3 fulfills the conditions, it is the index 2 and so on.
Why it only works as array formula? Because the IF function do not creates a array by default even if their "Value_if_true" is a range. Within the array context it does exact this.
I am having no luck trying to count my non blank cells in excel. I have tried multiple formulas and I keep getting inaccurate data. Here is the situation:
I am creating a Preventative Care list for my physicians (I have 4) I created a list of all their patients that have received a letter re: Prev. Care and I am inputting who needs a second letter and who has results. Some results are negative, some are positive. I have the list set up in alphabetical order on patients last name and then I have their physician initials in the other column. I want to check to see what percentage of each doctors patients have done their prev. care. I want to calculate this separately. Unfortunately, the cells are no in order. I have tried everything to my knowledge.
Help!
This will give you how many blank cells you have. You can deduct this from the total number of cells in your column, or you could use this directly to compute your percentage as (1 - x) where x is percentage of blank cells.
=COUNTBLANK(<your column>)
E.g:
=COUNTBLANK(A1:A10)
If it's not immediately obvious how to count the total number of cells in a range, this formula should help explain, answering the original question fully. It works with ranges that span more than 1 column, too.
=ROWS(range)*COLUMNS(range)-COUNTBLANK(range)
You might try something like:
=IF(LEN(A1) > 0, 1, 0)
You can then sum that column or do whatever other calculation you need.
=COUNTIF(range,"<>"&"") will count all cells that do not have a value equivalent to "", so, basically anything that is not blank.