Excel: Using an IF() Function with Conditions Depending on Other Cells - excel

I am writing an excel script for my company, and I am getting hung up on something. I have written a formula that calculates pay for a certain benefits we have.
This paragraph explains parts of the spreadsheet that work. If the employee was here for at least a year, they receive their benefit. If not, they are not eligible. I have a column that has a condition for their eligibility using the IF() function and determines whether or not they are eligible by their hire date. I also have a column that says the total pay from their benefit (6 percent of their normal hourly rate multiplied by their hours worked).
The issue I need help with is the last separate column that determines their pay if they are in fact eligible. What I want to do, is if the eligibility is true, have the cell display their benefit pay. If they are not eligible, I want the cell to display 0 (I already have a column saying if they are eligible or not to prevent confusion).
The formula I currently have looks like this:
=IF(V2="Eligible for SWW Pay",=T2,=0)
where V is the eligibility column and T is the pay given from their benefits. The formulas in both T and V give the correct output. However, this formula for the last column gives me an error. I don't know if it is a syntax error or if my logic is totally wrong for doing this.
Does anyone have any idea what I am doing wrong? Any feedback is greatly appreciated!
Thanks,
Nick

I would propose you the following formula:
=IF(V2="Eligible for SWW Pay",T2,0)
The equal-signs in front of T2 and 0 are not needed.

Related

How do I sum several rows by category? (EXCEL)

I have created an excel sheet to have an overview over costs in my projects, however, I also need an overview of costs per category in my projects. I googled it and tried to find examples online, however, it only returns a value of 0, which shouldn't be the case. Can anyone help me? The sheet looks like below.
I am going by the SUMIF function to group by category but my excel sheet is a bit more complex than that so I tried to adjust it accordingly as seen in the code below. No matter what I do it either returns an error or 0.
=IF(B12=B8;"";SUMIF(B12:B39;B12;J12:BE39))
In the formula above I am trying to sum the costs of a category that could be written in B12, for example, Software development. For confidential reasons, I cannot show the actual filled out excel sheet.
sumif does not work with summing multiple columns. Instead use a sumproduct statement instead like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$BE$39)))
A detailed explanation to how this works can be found here
Edit:
I sense a follow up question coming, how to skip certain columns. Because as you have set it up now, it will count the entire range from J12 to BE39, in which you have both forecast costs and actual costs. I guess this is to compare the costs to what was projected and what the actual costs are. Right now it will count both the projected and actual cost, doubling up. To prevent this you can enter every second column separated by a + like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$J$39+$L$12:$L$39+$N$12:$N$39)))
Also I have added $ signs to all non-changing values so it will work when dragging down the fill handle on the formula to populate the below cells.

How can I perform a conditional indirect sum in excel with an if function?

Sample Sheet
Profit
Sales
Expenses
COGS
Hello, I have an array of financial data that I need to turn into profit. I have been able to successfully sum all of the financial together based on a specific date range, but I have encountered a problem with cost of goods sold. Using the match function (apologies if the format is ridiculous, I am new to stackoverflow; the formula is present in the google sheet as well):
=SUM(INDIRECT("'Sales'!"&SUBSTITUTE(ADDRESS(1,MATCH($C$1,Sales!$1:$1,0),4),1,"") &MATCH(A3,Sales!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH($E$1,Sales!$1:$1,0),4),1,"")&MATCH(A3,Sales!A:A,0)))+SUM(INDIRECT("'Expenses'!"&SUBSTITUTE(ADDRESS(1,MATCH($C$1,Expenses!$1:$1,0),4),1,"")&MATCH(A3,Expenses!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH($E$1,Expenses!$1:$1,0),4),1,"")&MATCH(A3,Expenses!A:A,0)))+SUM(INDIRECT("'COGS'!"&SUBSTITUTE(ADDRESS(1,MATCH($C$1,COGS!$1:$1,0),4),1,"")&MATCH(A3,COGS!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH($E$1,COGS!$1:$1,0),4),1,"")&MATCH(A3,Expenses!A:A,0)))
I can sum every value on every sheet by row when matching a list of IDs which is constant throughout all data sheets. My problem is: I only want to sum the cost of goods sold sheet to profit ONLY If there is a corresponding sales value in the same location but on the sales tab. Ive tried replacing the sum with sumif to no avail, as I am just getting the hang of this indirect functions. Can anyone provide me with any information that may help me better understand this problem I'd really appreciate it. Thanks
I think that the COGS was meant to be a one time expense per day. That is how all but the first example are calculated.
If so, I believe the correct answer is:
{=SUM(INDIRECT("'Sales'!"&SUBSTITUTE(ADDRESS(1,MATCH($C$1,Sales!$1:$1,0),4),1,"")&MATCH(A3,Sales!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH($E$1,Sales!$1:$1,0),4),1,"")&MATCH(A3,Sales!A:A,0)))+SUM(INDIRECT("'Expenses'!"&SUBSTITUTE(ADDRESS(1,MATCH($C$1,Expenses!$1:$1,0),4),1,"")&MATCH(A3,Expenses!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH($E$1,Expenses!$1:$1,0),4),1,"")&MATCH(A3,Expenses!A:A,0)))+SUMPRODUCT(IFERROR(INDIRECT("'Sales'!"&SUBSTITUTE(ADDRESS(1,MATCH($C$1,Sales!$1:$1,0),4),1,"")&MATCH(A3,Sales!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH($E$1,Sales!$1:$1,0),4),1,"")&MATCH(A3,Sales!A:A,0))/INDIRECT("'Sales'!"&SUBSTITUTE(ADDRESS(1,MATCH($C$1,Sales!$1:$1,0),4),1,"")&MATCH(A3,Sales!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH($E$1,Sales!$1:$1,0),4),1,"")&MATCH(A3,Sales!A:A,0)),0),INDIRECT("'COGS'!"&SUBSTITUTE(ADDRESS(1,MATCH($C$1,COGS!$1:$1,0),4),1,"")&MATCH(A3,COGS!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH($E$1,COGS!$1:$1,0),4),1,"")&MATCH(A3,Expenses!A:A,0)))}
Without more info I can only come up with that.
=SUM(Sales!B2:I2)+SUM(Expenses!B2:I2)-SUMPRODUCT((Sales!B2:I2<>0)*(COGS!B2:I2))
or
=SUMPRODUCT((Sales!B2:I2)*($C$1<=Sales!B1:I1)*($E$1>=Sales!B1:I1))+SUMPRODUCT((Expenses!B2:I2)*($C$1<=Expenses!B1:I1)*($E$1>=Expenses!B1:I1))-SUMPRODUCT((Sales!B2:I2<>0)*(COGS!B2:I2)*($C$1<=COGS!B1:I1)*($E$1>=COGS!B1:I1))
if dates matters
With the sheet you provided it returns 3.2
Why did you used so much indirect & substitute?
Was it required or fixed ranged fits your need ?

EXCEL calculating average with OFFSET (coord unspecified) of a given keyword

Fun situation I'm trying to calculate. Basically in one row I have names of products, and the row to the right of it the number of days that have passed since the product was first received.
The calculation to do the days for ex is
=TODAY()-BB2
What I'm trying to do NOW, is identify let's say the product word "truck," and then calculate how many days on average the holding time of truck is.
I understand the logic of the formula I need, just not how to execute precisely. Basically the formula is going to need to use this average calculator with a keyword identified COUNTIF
=COUNTIF($A$2:$A$900,"TRUCK")/COUNTA($A$2:$A$900)
What I'm missing is some type of...IF "TRUCK, OFFSET (GIVEN CELL) -1)
Thanks for any thoughts!
-Wilson
A formula (in C1 in the example):
=AVERAGEIF(A:A,"truck",B:B)
should work but I would recommend a PivotTable for the additional functionality it provides:

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.

Excel 2013: Count unique values or IDs in column B with a condition which needs to be filtered in column A

I am a noob in excel, hence pardon me for any mistakes made.
This question must have been answered before but I couldn't find the right string to make it work for me.
There are around 500 rows and 20 columns (Yes, it is a report)
Column A has a few values (eg: Problem, Change, Request, etc.)
Column B has ticket numbers assigned to each entry. (No, I don't work for a call center, these are Datacenter Operations tickets)
Column B has several duplicate ticket numbers, as many people worked on same ticket OR the ticket was reopened for some reason.
I wish to take a count of unique ticket numbers from Column B when the condition in Column A is Change only.
So if there are 500 ticket number 250 are duplicate for sure, and only 25% of the rest will be Change tickets.
I am not supposed to use a Pivot or filter hence asking this question.
Need a formula to retrieve the count with the condition.
I may put the formula in Sheet2 or at the extreme right column, plz don't worry about it, I will take care of those things.
Many thanks in advance.
Adding to the question,
Let me help you with some data.
Change CRQ1110001
Problem INC1110001
Change CRQ1110001
Problem INC1110001
Change CRQ1110003
Problem INC1110003
Change CRQ1110004
Problem INC1110004
Change CRQ1110004
Change CRQ1110004
Problem INC1110005
Now I wish to only consider Change here without considering duplicate values.
Maybe this helps.
Thanks again.
Based on this website count unique values and with a small change this formula should work, expand the ranges to cover your entire range.
=SUM(IF(FREQUENCY(IF(A2:A10="change",IF(LEN(B2:B10)>0,MATCH(B2:B10,B2:B10,0),""),""), IF(A2:A10="change",IF(LEN(B2:B10)>0,MATCH(B2:B10,B2:B10,0),""),""))>0,1))
Entered with ctrl+shift+enter as it's an array formula.
Note that if you do this over the entire column A:A it will take quite a bit of time to compute as it has to go through a lot of calculations in the array formula.
If your "ticket numbers" in column B are actual numbers then you can use this formula
=SUM(IF(FREQUENCY(IF(A2:A500="Change",B2:B500),B2:B500),1))
confirmed with CTRL+SHIFT+ENTER
If not numeric you need to use a version as per gtwebb's suggestion

Resources