Need help on getting specific information from an excel formula - excel

I work for a company that has multiple locations selling auto parts. I'm wanting to look at the 'freshness' of the inventory, but for a specific year range for specific vehicle(s).
The basic formula I'm using is
=COUNTIFS(INVENTORY!$A$2:$A$50000,$B$1,INVENTORY!$I$2:$I$50000,$J$117,INVENTORY!P$2:P$50000,$C$118)
Result is 4
The first argument is looking at the location, the second is looking at the particular vehicle. The third is determining whether the inventory is either 30, 60 or 90 days old, and I'm getting the right information. What I want to know now is, while looking at those 4 vehicles, how many of those are made between the years 2004 to 2010, so the criteria for the 4th argument has a range within it, not one specific year (I know the result should come back as 1 in either the 30, 60 or 60+ cell). On the inventory sheet, the years of the vehicles are in column 'E'. I'm not sure if I need to use imbedded IF statements to specify the year range, or need to rewrite the whole formula. Can anyone give me some advise on how to write the formula to get this info?

You can add two conditions to your COUTINFS on the same E column for the year, i.e.
=COUNTIFS(INVENTORY!A:A,$B$1,INVENTORY!I:I,$J$117,INVENTORY!P:P,$C$118,
INVENTORY!E:E, ">=2004", INVENTORY!E:E, "<=2010")
The second line above shows the additional consitions. If the range of years is dynamically present in cells, say C1 and D1, the criteria should be composed by concatenation, i.e.
=COUNTIFS(INVENTORY!A:A,$B$1,INVENTORY!I:I,$J$117,INVENTORY!P:P,$C$118,
INVENTORY!E:E, ">="&C1, INVENTORY!E:E, "<="&D1)
' ^^^^^^ ^^^^^^

Related

Conditionally format a cell based on all of the values of a range of cells

I am trying to create an editable calendar of availabilities, wherein people can input that they are available either during the day, at night, all day, or not at all.
I would like the calendar to automatically highlight days when there is an overlap of availability - say, when everyone is free at night, or some are free all the time and one only during the day.
I can do the former by using the formula =AND(($C2:$G2)="night") - when all five people input "night", it highlights as fully available. However, my problem is with the "All the time" variable.
How would I create a conditional format that highlights cell A2 (for example) when all of the cells in range C2:G2 are filled with either "day" or "both"? So far I've gotten to =OR($C2:$G2="day",$C2:$G2="both"), but this has the problem of highlighting A2 if even just one cell in the range has the desired value. I assume I have to include an AND command here, but how exactly?
Thank you for any help :)
Screencap of calendar: Columns A and B are filled with days/dates. C1:G1 are labelled Person 1 - Person 5. Each person has filled an availability for each date, either "night", "day", "both", or "NA".
Another solution would to be using a couple COUNTIF() functions and comparing to the total, in your case 5 since you have 5 columns.
Sum the results of the two COUNTIF() functions, if they equal 5, your data is highlighted:
=COUNTIF($C2:$G2,"day") + COUNTIF($C2:$G2,"both") = 5
Essentially, if the left side of your equation is equal to the right side then it will return True.
This can be a little more portable. Only need 3 or more of the 5 cells? You could simply change to >= 3 instead of being = 5.
In the event no one is able to come up with a more elegant solution, here's one that at least would work for you. Not too bad if you only need to compare the 5 columns, could be a bit more painstaking if you have more.
=AND(OR($C2="day",$C2="both"),OR($D2="day",$D2="both"),OR($E2="day",$E2="both"),OR($F2="day",$F2="both"),OR($G2="day",$G2="both"))
The And() function, as you are likely already aware, requires that each and every value within it returns a True value to have it output a value of True.

Sum values based on date compared to current date

I am currently trying to create an if statement that sums values based on whether a date has passed.
Excel example image
M1 to M12 dictate the months of the year e.g. 01/01/2021 for M1 and 01/12/2021 for M12
Now I want to create or use a formula that sums the values in row 4 based on what month we are currently in --> If we are currently in M1, e.g. 15/01/2021, then it only needs to sum the value in A4. However, if we are, for example, in M3 (28/03/2021) then it needs to sum A4 + B4 + C4
I tried using the following formula but the problem is that when it finds a value larger than 01/01/2021 it doesn't take other months into consideration anymore
=IF(TODAY()>=A2;A4;IF(TODAY()>=B2;SUM(A4:B4);0))
I added the zero at the end of the function to close the formula but my idea was to prolong it up til 12 months. However, it only ever sums the first cell (A4) because conditions have already been met. How do I 'overwrite' the first condition if more months have passed?
Any help would be greatly appreciated; I excuse myself for asking potentially dumb questions but Excel isn't my strong point and I am trying to learn.
Kind regards,
VHes
Try:
=SUM(INDEX(4:4,SEQUENCE(MONTH(TODAY()))))
An alternative approach using SUMIF:
=SUMIF(A2:L2,"<"&EOMONTH(TODAY(),0),A4:L4)
If SEQUENCE is not supported by your version of excel, (based on comments it does), you could also try the following:
=SUM(A4:INDEX(A4:L4,MONTH(TODAY())))
The trick here is that INDEX actually supplies a cell address, and displays the contents of that cell when needed.

Indirect index and match problem formula in different named tables

I have a cell where I want to get the tax% based on a criteria
Coming from "Taxes", depends on manufacturer country, year of release and car type
I've tried to use search and index and its not working at all, I need the cell to check values in the manufacturer country, year of release and car type use these inputs go to the Taxes sheet and get the value
Before I start, I should come clean and say I am an evangelist for the OFFSET() function, and a mortal foe of INDIRECT().
Let's assume that the number of vehicle types (TRUCKS, SEDANS, ....) is the same for each country, ie 8. (If its not then that can be worked around with a bit more effort). You could put this number in a cell somewhere and use it when you need the number of types.
Also, let's say the first column in your screenshot is column A. And that the cell A1 contains "China".
Let's say we are looking for the tax rate in 2009, for SEDANS in France.
Function 1:
=MATCH("France",$A:$A,0) will return 14 (if I have counted correctly)
... ie cell A14 contains the word "France".
On the assumption that the years are the same for all countries we can use any of the header rows to find the right column.
Function 2:
=MATCH(2009,$3:$3,0)-1 will return 8 I think.
If your years are just strings of text, then replace 2009 with "2009".
Because your Types are not in the same order in each table (why?) we need an extra step.
Function 3:
=MATCH("SEDANS",OFFSET($A$1,(Result of f1) -1 + 3,0,8,1),0) should return 3.
What is the maths in the OFFSET function? I need to go down (14-1) rows from cell A1 to get to "France". From there I need to go down another 3 rows to get to the first of the list of Types, and there are 8 types to search in. I'm then looking at a range of cells which is 8 rows x 1 column.
Now you can extract your tax rate, using
Function 4:
=INDEX(OFFSET($A$1,(Result of f1) -1+3,1,8,100),(Result of f3),(Result of f2))
(I've put 100 as I don't know how many columns of years you have. You could use something like =COUNTA($3:$3)-1 if there was nothing else in the 3rd row after the last date).
I would put the results of each function in a cell while you test this. Once you are happy that each step is working correctly you can nest all the various functions together, or alternatively just put some extra columns on the right hand side of your results table, which you can Hide if you want to.
EDITED: To add some $ on cell references to lock the "origin" of the data.
If your tax tables are real Tables, each NAME'd with the name of the respective country, you can use something like:
=VLOOKUP(H13,INDIRECT(H12),MATCH(TEXT(H14,"0"),INDIRECT(H12 & "[#Headers]"),0))
where
H12 contains the name of the country
H13 contains the Type of vehicle
H14 contains the Year
eg:
You'll need to adapt this to your real ranges, but this provides an approach.
I'd suggest using dropdown lists (from Data Validation) in H13:H14 in order to avoid typos.
If you want to avoid using Tables and also the volatile functions OFFSET and INDIRECT (because if you have a lot of volatile functions they can impair performance of your worksheet) you can try the non-volatile, but longer and more obscure:
=VLOOKUP($H$13,INDEX($A:$A,MATCH($H$12,$A:$A,0)):INDEX($D:$D,LOOKUP(2,1/($A:$A<>""),ROW($A:$A))),$H$14-2000,FALSE)
In the above, you'll have to make adjustments
Assumptions are:
The country name is above the relevant tax table
Tax table starts in Column A
Change references to Column A if it does not start there.
Change the reference to Column D to the last column of your tax table (or even further if you will be expanding it).
The Year columns are labelled the same for all countries (eg: consecutive years starting at 2002)
$H$14-2000 calculates the column argument for the VLOOKUP function.

Excel 2013 advanced date range lookup using sumproduct

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.

Conditional IF Statement in Excel, Change Other Cells According to Content

I'm trying to make a revision timetable for myself on Excel.
Let's say I'm doing four exams, A to D. Each exam has a certain number of "practice papers" that I have to do. Below is a demonstration table on Excel:
ExamName NoOfPapers
ExamA 4
ExamB 5
ExamC 7
ExamD 1
There is another table, with two columns: MonthDate and the paper I want to practice on that da. So,
May Paper?
1
2
.
.
.
29
I want to make it work so that if I put ExamA in the field under Paper?, it would automatically deduct 1 from the NoOfPapers of ExamA, to make it 3, so I make sure I'm not repeating the paper too many times.
If I only had 17 papers, it would have been easy to do it manually. But unfortunately I have 99 papers to do (exactly 99 :P).
How can I implement this on a cell as an IF statement (or any other possible way) on Microsoft Office Excel?
Thank you! :)
change the title of the column "NoOfPapers" to "OriginalNoOfPapers". Then create a column next to it called "NoOfPapersRemaining".
Assuming the cell with "ExamName" is A1, use the following formula in C2: =B2 - COUNTIF(Z:Z, A2)
(this also assumes that the column called "Paper?" is in column Z... in real life change it to the correct column on your spreadsheet.
I made four columns in row 1, Exam Name, Exam Total, Completed,Remaining. The completed column has the function
=Countif(B:B,A:A)
in roww 2, 3, 4, 5. The remaining columns are
D2="SUM(B2-C2)"
D3="SUM(B3,C3)"
D4="SUM(D4,C4)"
D5="SUM(D5,C5)"
In row 7 I have three columns, Date Complete, Exam Name, Paper. Exam Name must = The exact same as Cell A2:A5. All you would need is to enter the date and the exam name and it will show the total papers done and the remaining.
This can be better but does what I believe you asked. For instance, use of conditional formatting. If there is a deadline, add a column for the date and use conditional formatting to display an approaching deadline. Freeze row 7 to see remaining after entering a lot of dates in cell A8.
Hope this helps. I'm not a pro but like learning more about Excel.

Resources