what formula to use in excel when trying to subtract - excel

I have a list of numbers that i need to subtract to 60 when the number is greater than 60. is there any one here knows on what formula to use and how for me to do this????
for example:
61 = 1
75 = 15
52 = 52
using the needed formula this should be the result

Use IF condition.
The syntax for the Microsoft Excel IF function is:
IF( condition, [value_if_true], [value_if_false] )
Formula
=IF(A1>60,A1-60,A1)
Test link

I'm assuming this is number of seconds or minutes, and you want to clip it at 60 to wrap it around. This will do it:
=MOD(A1,60)
Otherwise use the If function like Ullas indicated above.

Related

Excel french issue

I have Excel sheet with value and another column value that depend of theme
If value >48 the value will be 8 if <=40 value will be 0 if value inferior a 48 and supperieru a 40 value will be column -40 I tried this but didn't work
=SI(AH15>48,8,SI(ET(AH15>40,AH15<48,AH15-40))
Or english:
=IF(AH15>48,8,IF(AND(AH15>40,AH15<48,AH15-40))
You are throwing in an AND function to check multiple conditions in a wrong manner:
All these conditions ET(AH15>40,AH15<48,AH15-40) can never be true since the last parameter is a calculation. Either way, what you tried to do is maybe:
=SI(AH15<=40,0,SI(AH15>48,8,AH15-40))
Which translates to:
=IF(AH15<=40,0,IF(AH15>48,8,AH15-40))
Try this one:
=IF(AH15>48,8,IF(AND(AH15>40,AH15<=48),AH15-40,0))
Hope it helps

Multiple custome date format for one column?

Can we put up a OR command for custom time in one column?
I have multiple time formats in one column of excel. For eg:
Timing
30 min
31 sec
4 min 20 sec
1 hr 2 min
3 hr
1 hr 23 min 30 sec
I want to convert it to time format: hh:mm:ss so that i can calculate average from all times. How can I achieve it?
Here's a shorter formula:
=TIME(IF(IFERROR(FIND("hr";$A2);0)=0;0;IFERROR(MID($A2;IFERROR(FIND("hr";$A2);0)-3;2);MID($A2;IFERROR(FIND("hr";$A2);0)-2;1)));IF(IFERROR(FIND("min";$A2);0)=0;0;IFERROR(MID($A2;IFERROR(FIND("min";$A2);0)-3;2);MID($A2;IFERROR(FIND("min";$A2);0)-2;1)));IF(IFERROR(FIND("sec";$A2);0)=0;0;IFERROR(MID($A2;IFERROR(FIND("sec";$A2);0)-3;2);MID($A2;IFERROR(FIND("sec";$A2);0)-2;1))))
Note: the above formula contains semicolon (;) as a separator. Replace with coma (,), in case this is your system separator.
To be honest I did not try to decipher #Foxfire's formula.
Remember to apply custom time format to the result cell: [h]:mm:ss
For explanatory reasons see breakdown of the long formula:
This huge formula worked for me:
=IF(AND(IFERROR(FIND("hr";A1;1);0)>0;IFERROR(FIND("min";A1;1);0)>0;IFERROR(FIND("sec";A1;1);0)>0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1;" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)>0;IFERROR(FIND("min";A1;1);0)>0;IFERROR(FIND("sec";A1;1);0)=0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A1)&" 00 sec";" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)=0;IFERROR(FIND("min";A1;1);0)>0;IFERROR(FIND("sec";A1;1);0)>0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("00 hr " & TRIM(A1);" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)>0;IFERROR(FIND("min";A1;1);0)=0;IFERROR(FIND("sec";A1;1);0)=0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM(A1)&"00 min 00 sec";" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)=0;IFERROR(FIND("min";A1;1);0)>0;IFERROR(FIND("sec";A1;1);0)=0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("00 hr " & TRIM(A1)&" 00 sec";" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");IF(AND(IFERROR(FIND("hr";A1;1);0)=0;IFERROR(FIND("min";A1;1);0)=0;IFERROR(FIND("sec";A1;1);0)>0);TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("00 hr 00 min "&TRIM(A1);" ";"");"hr";":");"min";":");"sec";"");"hh:mm:ss");"Formula needs to be updated"))))))
As I said, you need to check every string in your text. Depending if it contains hr,min,sec, you need to calculate the time and then convert it to time. Also, you need to take care of those annoying blanks at end of some strings. This formula does all this.
Hope you can adapt this to your needs. My Excel is in spanish, but I translated formulas manually. Just in case I typed wrong, I uploaded a file example to Gdrive for you to download and check the formulas (they should autotranslate if you open it).
https://drive.google.com/open?id=13J5IWLOFFZpzvIp1oqPwqkE3eHDk7EeH

Convert number to string in Excel

I'm trying to do some transformation with numbers in excel. First i have that table:
And as you can see, i have Random Digits, which is generated by using RANDBETWEEN. Now i want the Column Type, to be automatically Generated. So for example if Random Digits is:
From 1 - 35 = Good
36 - 80 = Fair
81 - 100 = Poor
I was already trying with IF function, but with if function i'm able to generate only 2 values and not 3.
Thank you for answers.
INDEX and MATCH are a good way to avoid nesting lots of IF statements (generally to be avoided!):
=INDEX({"Good","Fair","Poor"},MATCH(B2,{0,36,81},1))
If you really wanted to use an IF statement, it would look like this:
=IF(B2<36,"Good",IF(B2<81,"Fair","Poor"))
Nest the If so where you get the true value just output what you need but if its false then just write another if statement...
Use one IF inside another IF like this:
=if('From 1 - 35';'thing to do if is true';if('36 - 80';'thing to do if is true';'thing to do when is 81 - 100'))
The excel formula you are looking for is
=IF(B1>100,"error",IF(B1>=81,"Poor",IF(B1>=36,"Fair",IF(B1>=1,"Good","error"))))
This will display the word "error" if you range is >100 or <1. Other answers have failed to address the cases where the number is >100 or <1, as the question specifically bounds the set of responses to be between 1 and 100.
The formula works as a nested if statement. In pseudo code the formula is equivalent to:
if(B1>100)
then "Error"
Else if (B1>=81)
then "Poor"
Else if (B1>=36)
then "Fair"
Else if (B1>=1)
then "Good"
else
"Error"

MS Excel if statement

This may be really easy for someone who used excel allot in the past but i just can't get the right formula.
I have a large spreadsheet which i need to add a mark up onto but the mark up which adds on is dependent on variables. Unfortunately this result has to go on the end of a already big formula, the ######## represents where the IF statement will be placed.
IF >55 and is square = 15
IF >55 and is not square = 15
IF <55 and is Square = 25
IF <55 and is not square = 30
Cell D2 = has the numerical value
Cell G2 = Has the shapes in it.
=(((100-V2)/100)*U2*D2)+((((100-V2)/100)*U2*D2)/100*##########)
I really recommend you break the formula into cells, but if it's needed to be in one single cell, the formula can be done as well...
IF(D2>55;IF(G2="square";15;15);IF(G2="square";25;30))
So it's gonna be like:
=(((100-V2)/100)*U2*D2)+((((100-V2)/100)*U2*D2)/100*IF(D2>55;IF(G2="square";15;15);IF(G2="square";25;30)))
A little shorter (addresses D2=55):
=15+15*(D2<55)-5*(D2<55)*(G2="Square")
I am not a big fan of the nested ifs in Excel, especially when they contain and/or conditions. The typical formula would look something like:
=if(and(c1,c2),x1,if(and(c3,c4),x2,...
YUCK!
I'm definitely a VBA minimalist, but this does appear to be a good application of it. Make a custom function like:
Function FooBoo(Val As Integer, Shape As String) As Integer
Dim result As Integer
If Val > 55 And Shape = "square" Then
result = 15
ElseIf Val > 55 Then
result = 15
ElseIf Val < 55 And Shape = "square" Then
result = 25
ElseIf Val < 55 Then
result = 30
End If
FooBoo = result
End Function
And then you can call it from within Excel:
=(((100-V2)/100)*U2*D2)+((((100-V2)/100)*U2*D2)/100*FooBoo(val,shape))
If it's part of the workbook itself, it's no less portable than any other Excel formula, and it's more transparent and easier to maintain.
Also, unrelated, but I did note some things in your logic:
15 seems to be the result for values > 55, whether or not it's a square. You really could limit your first condition to values > 55
You haven't defined what happens if the value is exactly 55. Was one of those conditions >= or <=?

How to exclude 0 from MIN formula Excel

i need to know how can i exclude 0 from rows and get the MIN Value.
But also i need to exlude the F1 Cell.
Ex:
A B C D E F
1 0 18 20 0 150 = 18
but if i do this In excel with =MIN(A1,B1,C1,D1,E1) return 0.
Any help is appreciated.
Try this formula
=SMALL((A1,C1,E1),INDEX(FREQUENCY((A1,C1,E1),0),1)+1)
Both SMALL and FREQUENCY functions accept "unions" as arguments, i.e. single cell references separated by commas and enclosed in brackets like (A1,C1,E1).
So the formula uses FREQUENCY and INDEX to find the number of zeroes in a range and if you add 1 to that you get the k value such that the kth smallest is always the minimum value excluding zero.
I'm assuming you don't have negative numbers.....
Enter the following into the result cell and then press Ctrl & Shift while pushing ENTER:
=MIN(If(A1:E1>0,A1:E1))
Not entirely sure what you want here, but if you want to discount blank cells in the range and pass over zeros then this would do it; if a little contrived:
=MIN(IF(A1:E1=0,MAX(A1:E1),A1:E1))
With Ctrl+Shift+Enter as an array.
What I'm doing here is replacing zeros with the maximum value in the list.
if all your value are positive, you can do -max(-n)
Solutions listed did not exactly work for me. The closest was Chief Wiggum - I wanted to add a comment on his answer but lack the reputation to do so. So I post as separate answer:
=MIN(IF(A1:E1>0;A1:E1))
Then instead of pressing ENTER, press CTRL+SHIFT+ENTER and watch Excel add { and } to respectively the beginning and the end of the formula (to activate the formula on array).
The comma "," and "If" statement as proposed by Chief Wiggum did not work on Excel Home and Student 2013. Need a semicolon ";" as well as full cap "IF" did the trick. Small syntax difference but took me 1.5 hour to figure out why I was getting an error and #VALUE.
Throwing my hat in the ring:
1) First we execute the NOT function on a set of integers,
evaluating non-zeros to 0 and zeros to 1
2) Then we search for the MAX in our original set of integers
3) Then we multiply each number in the set generated in step 1 by the MAX found in step 2, setting ones as 0 and zeros as MAX
4) Then we add the set generated in step 3 to our original set
5) Lastly we look for the MIN in the set generated in step 4
{=MIN((NOT(A1:A5000)* MAX(A1:A5000))+ A1:A5000)}
If you know the rough range of numbers, you can replace the MAX(RANGE) with a constant. This speeds things up slightly, still not enough to compete with the faster functions.
Also did a quick test run on data set of 5000 integers with formula being executed 5000 times.
{=SMALL(A1:A5000,COUNTIF(A1:A5000,0)+1)}
1.700859 Seconds Elapsed |
5,301,902 Ticks Elapsed
{=SMALL(A1:A5000,INDEX(FREQUENCY(A1:A5000,0),1)+1)}
1.935807 Seconds Elapsed |
6,034,279 Ticks Elapsed
{=MIN((NOT(A1:A5000)* MAX(A1:A5000))+ A1:A5000)}
3.127774 Seconds Elapsed |
9,749,865 Ticks Elapsed
{=MIN(If(A1:A5000>0,A1:A5000))}
3.287850 Seconds Elapsed |
10,248,852 Ticks Elapsed
{"=MIN(((A1:A5000=0)* MAX(A1:A5000))+ A1:A5000)"}
3.328824 Seconds Elapsed |
10,376,576 Ticks Elapsed
{=MIN(IF(A1:A5000=0,MAX(A1:A5000),A1:A5000))}
3.394730 Seconds Elapsed |
10,582,017 Ticks Elapsed
min() fuction exlude BOOLEAN and STRING values.
if you replace your zeroes with "" (empty string) - min() function will do its job as you like!
In Microsoft 365 you can use the new function MINIFS
=MINIFS(A1:E1;A1:E1;">0")
gives 1
=MINIFS(A1:E1;A1:E1;">1")
gives 18
*replace ; with , if using english version
All you have to do is to delete the "0" in the cells that contain just that and try again. That should work.

Resources