create formula with sumif,if and ,or - excel

I want to make formula with sumif and with conditions i tried but its failing to provide sum.I want to find value if conditions:
1. G/L is 62810101 or 62810100 then value for 81810101 and 81810100 should be calculated or vice versa.
2.If code is A2+B2 then value for B2+A2 should be find in document currency.
i tried something like this... =IF(OR(E2=62810101,E2=62810100),SUMIFS(I:I,L:L,L2,E:E,E2=81810101))
CoCd Tr.Prt DocumentNo Reference G/L Doc. Date Amount in local cur. LCurr Amount in doc. curr. Curr. Code 1 Sum if 1
BG05 RS31 1100000007 111 62810100 42081 2542.58 BGN 1300 EUR BG05RS31 2918
BG05 RS31 1100000017 1100000017 81810101 42234 621.95 BGN 318 EUR RS31BG05 318

Try these formula:
For Accts Receivable:
=SUM(SUMIFS(I:I,L:L,L2,E:E,{62810101,62810100}))
For Accts Payable:
=SUM(SUMIFS(I:I,L:L,L2,E:E,{81810101,81810100}))
It is just a matter of putting the wanted account numbers in the {} brackets.

Related

Finding the closest date, that is most recent date - 1 year's value

I have the following table, table1:
date
value
05/04/2022
400
22/04/2022
312
04/05/2022
942
06/08/2022
231
12/08/2022
243
I want to get the most recent date in the table (in this case 12/08/2022) and minus 1 year from it to get 12/08/2021. Then look at the table to find the value that is most closest to 12/08/2021. In this case, the closest value is from the table is 05/04/2022, so the formula will return 400.
I tried with this formula, but really unclear how to do it.
=VLOOKUP(IFERROR(MAX(Table1[date])-365,MAX(Table1[date])), Table1, 2,TRUE)
I have Microsoft Excel 2020
If you have Excel 365 you can use this formula:
=LET(mostRecentDate,MAX(table1[date]),
previousYearDate,mostRecentDate-365,
MIN(FILTER(table1[date],table1[date]>previousYearDate))
)
If you don't have the FILTER-function try this:
=INDEX(table1[date],MATCH(MIN(ABS(table1[date]-(MAX(table1[date])-365))),ABS(table1[date]-(MAX(table1[date])-365)),0))
It checks for the differences to the max-date - 365

#NUM! error when formula calculating % complete for future dates

I've got a worksheet that shows employee assignments, as well as their contract start and end dates. in column D I calculate the percent that this contract is completed.
My formula is working for current and past dates, but future dates result in #NUM!. I have a feeling this is because the calculation is either impossible or less than 0.
I've tried to correct this but it's currently beating me. Any suggestions to fix this?
Formula:
=IF(ISBLANK(B2),"",IF((DATEDIF(B2,TODAY(),"d")+1)/(DATEDIF(B2,C2,"d")+1)>99.99%,1,IFERROR((DATEDIF(B2,TODAY(),"d")+1)/(DATEDIF(B2,C2,"d")+1),0)))
Data:
A B C D
1 Name Start Date End Date Contract % Complete
2 Allen 8/21/17 8/24/18 100.00%
3 Billy 12/4/17 12/8/18 72.16%
4 Charles 9/6/18 12/28/18 #NUM!
The issue is that a Date can not be negative and DATEDIF(B2,TODAY(),"d") tries to return a negative date.
If the date is in the future then it is 0% finished.
Add an IFERROR to deal with that:
=IFERROR(IF(ISBLANK(B2),"",IF((DATEDIF(B2,TODAY(),"d")+1)/(DATEDIF(B2,C2,"d")+1)>99.99%,1,IFERROR((DATEDIF(B2,TODAY(),"d")+1)/(DATEDIF(B2,C2,"d")+1),0))),0)
Because 1 day to Excel is 1 we can get rid of the DATEDIF. Then using MAX and MIN to get rid of the nested IF and IFERRORs, we can simplify the formula to:
=IF(ISBLANK(B2),"",MAX(MIN((TODAY()-B2+1)/(C2-B2+1),1),0))

Excel: how to NOT sum based on text values?

I am trying to sum values based on another text column.
Let's say my data look like this:
date item amount
4/3/03 book 100
8/3/05 rent 1090
5/6/06 food 5
2/7/09 repair 390
8/3/10 rent 1090
so I want to sum all the spendings (amount) when the "item" section is NOT equal to "rent", but I dont just want a grand sum, I just want a sum that's up to that date.
So the desired output (last column, subtotal) should look something like this:
date item amount subtotal
4/3/03 book 100 100
8/3/05 rent 1090 100
5/6/06 food 5 105
2/7/09 repair 390 495
8/3/10 rent 1090 495
I've tried to sum it up while filtering the rolls to only show anything but rent, but when I clear the filter, all the numbers will sum INCLUDING rent.
I've also tried using SUMIF (I named the top cell in "Amount" column as "first_amount"):
=SUMIF(C2,"rent",first_amount:E2)
But I dont think I'm using it correctly or maybe it just doesn't work. It shows no value whatsoever.
I found this post and read through the function pages, but still am not being able to do what I wanted to do:
Excel summing values based on multiple conditions
BONUS:
What if I want to exclude both "rent" and "food"?
I'm sure there's a very simple solution out there that I am just too dumb to think of. Any hint/help is truly appreciated!
Assuming A1 is the first cell make D1:
=SUMIF($B$2:B2, "<>rent", $C$2:C2)

Excel function to choose a value greater than or less that a particular value in cell

I have a data set something like this
Units Price
1 15
100 10
150 9
200 8
50000 7
I need the output as Price with respect to quantity.
Example- If Input value is 90 it should give price as 15
If input is 210 it should give value as 8.
However,sadly I cannot use IF statement.
Thanks in advance.
You can use a combination of INDEX and MATCH
=INDEX(B1:B5,MATCH(lookup_value,A1:A5,1))
This assumes Units are in column A and Price is in column B
Make sure you understand both functions:
INDEX
MATCH - particularly the reason for the ,1) at the end
You can also use VLOOKUP. This is probably a bit easier although INDEX/MATCH is more versatile:-
=VLOOKUP(Lookup_value,$A$2:$B$6,2,TRUE)

In excel, I need to find the maximum date based on the employee number

I have tried to use the following formula when trying to find the max date of these columns based on the employee number in my hundreds of thousands lines of data. The formula bar gives me 'yes' when it is the max, however in my cell it says 'no'. I cannot figure out what the issue is. Thanks for the help.
Tamara
Excel Max date formula Image
Formula used: =IF(AQ2=MAX(IF($C:$C=C2,$AQ:$AQ)),"YES","NO")
A B Employee Number Max?
11-Mar-13 12-Mar-13 199 NO
24-Mar-13 26-Mar-13 199 NO
1-Aug-13 6-Aug-13 199 NO
22-Dec-13 27-Dec-13 199 NO
15-Apr-13 17-Apr-13 206 NO
18-Apr-13 18-Apr-13 206 NO
8-Aug-13 10-Aug-13 206 NO
17-Oct-13 18-Oct-13 206 NO
25-Dec-13 20-Feb-14 206 YES
8-May-13 8-May-13 214 NO
You can also accomplish this without an array is all of the dates for a specific employee ID are unique--that is, you won't have two of the same date. In this case, the following formula will check that (a) the number of dates with employee ID is equal to (b) the number of dates with employee ID that are less than or equal to the current employee ID. This will only be true for the "max" date for said employee id:
=IF(COUNTIFS($C:$C,C2)=COUNTIFS($C:$C,C2,$A:$A,"<="&A2),"Yes","No")
If I understand your question correctly, you want to find the set of dates with the largest time span in between said dates. If this is the case, then I would recommend using two seperate fucntions, the =DAYS360 function and the =MAX function.
I have re-created your sheet and it will end up looking similar to this:
Here is the same picture of the same sheet with functions revealed, so that you can see how the functions are used:
The =DAYS360 function takes two inputs, and return the number of days in between two dates. The max function simply finds the largest number in a range. Please let me know if this helped.
EDIT: Also, if you want to see the actual word Max next to the largest date range, you can nest the Max fucntion from my column E within an If function, like this:
=IF(MAX(D:D)=D2,"Max","")
If I understand you correctly, do you want "YES" to appear for each employee's max date range? Assuming column AQ contains the spans between dates in columns A and B (i.e. =B2-A2 copied down), your formula should work.
This only works as an array formula, so make sure you press CTRL+SHIFT+ENTER when entering the formula, then copy it down to all cells in the same column.
=IF(AQ2=MAX(IF($C:$C=C2,$AQ:$AQ)),"YES","NO"), entered in D2 using CTRL+SHIFT+ENTERand copied down produces the following:
A B C D ... AQ
11-Mar-13 12-Mar-13 199 NO 1
24-Mar-13 26-Mar-13 199 NO 2
1-Aug-13 6-Aug-13 199 YES 5
22-Dec-13 27-Dec-13 199 YES 5
15-Apr-13 17-Apr-13 206 NO 2
18-Apr-13 18-Apr-13 206 NO 0
8-Aug-13 10-Aug-13 206 NO 2
17-Oct-13 18-Oct-13 206 NO 1
25-Dec-13 20-Feb-14 206 YES 57
8-May-13 8-May-13 214 YES 0
If you are simply looking for the greatest date range, the formula =IF(E2=MAX($E:$E),"YES","NO") entered in D2 and copied down will do the trick.

Resources