I have spent a few hours working out how to do this which is why I'm posting it here now. I wanted that, for every 500 BDT it will charge 10 BDT. I wrote it with If formula.
For example:
IF J22 is ABOVE "0" BUT BELOW AND EQUAL "500" THEN display "10"
IF J22 is ABOVE "501" BUT BELOW AND EQUAL "1000" THEN display "20"
IF J22 is ABOVE "1001" BUT BELOW AND EQUAL "1500" THEN display "30"
IF J22 is ABOVE "1501" BUT BELOW AND EQUAL "2000" THEN display "40"
=IF(J22<500,10,IF(J22<1000,20,IF(J22<1500,30,IF(J22<2000,40,IF(J22<2500,50,IF(J22<3000,60,IF(J22<3500,70,IF(J22<4000,80,IF(J22<4500,90,IF(J22<5000,100,IF(J22<5500,110,IF(J22<6000,120,IF(J22<6500,130,)))))))))))))
I wrote it for 13 times again and again. And after that, I got angry if the amount is 22500BDT then I have to write the same thing for 225 times. Is there any shortcut formula for this?
The description of the function says IF J22 is ABOVE "0" BUT BELOW AND EQUAL"500" but the function you wrote says =IF(J22<500, so that's a bit of a quandary, but in general it looks like you're trying to add 10 to the result for every 500 or fraction thereof in your value. To do that you'd use something like
=(FLOOR(J22/500, 1)*10)+10
which is correct for the IF(J22<500 case. If you really wanted BELOW OR EQUAL "500" then use
=(FLOOR((J22-1)/500, 1)*10)+10
Presume the number you want to evaluate is in Cell J22, the following formula will work in the case of LESS THAN AND EQUAL TO 500
=ROUNDUP(J22/500,0)*10
and the following formula will work in the case of LESS THAN 500
=(ROUNDDOWN(J22/500,0)+1)*10
Related
I have a dataset of co-ordinates, except the co-ordinate is split into two column X and Y.
I'm trying to find the percentage of co-ordinates in a single quadrant, and thought IF/AND statements would work i.e.
IF "numbers in X Column is between -5 and 0" AND "numbers in Y is between -5 and 0" then display total as Percentage of all data
IF "numbers in X Column is between 0 and 5" AND "numbers in Y is between 0 and 5" then display total as Percentage of all data
Etc..
I think that may be the easiest way but I'm stuck on three things;
How to do it for negative numbers
How to do "is greater than a number BUT less than a number" (rather
than just greater/less than), and
How to show results as a percentage (I only know how to return a
TRUE or FALSE) i.e.:
=IF(AND(A2:A100>5,B2:B100>5),TRUE, FALSE)
If you have the newest version of Excel you can use FILTER.
For example, if you are looking for the percent of coordinates in Q1 (0<=X<=5, 0<=Y<=5), you can use something like:
=ROWS(
FILTER($A$2:$B$100,
(($A$2:$A$100>=0)*($A$2:$A$100<=5)*($B$2:$B$100>=0)*($B$2:$B$100<=5))))/
ROWS($A$2:$A$100)
If not, then a simple way is to do what you were originally trying in a helper column, and divide the results by the total rows.
To answer your questions:
For negative numbers, e.g. Q3, just use negative numbers. Something like:
=IF(AND($A$2:$A$100>=-5, $A$2:$A$100<=0, $B$2:$B$100<=0, $B$2:$B$100>=-5),1, 0)
Logically, it is not really "greater than a number BUT less than a number", but "greater than a number AND less than a number". The example in question 1 shows that in action.
To get as a percent, you add up all the values, and divide by the total. In an IF statement you can return anything (format is =IF(test_is_true, value1, value2)), so in the above example, I elect to return 1 for whenever a row meets our criteria.
I am struggling hard with the logic here.. COUNTIFS with OR condition for the criteria is fairly simple:
=SUM(COUNTIFS(range,criteria range1,{criteria1,criteria1.1},criteria range2,criteria2))
Though.. what if I need to have an OR condition on the range itself?
I have two columns containing week number for "Attempt 1" and "Attempt 2", then one with status, so my formula looks like this:
=SUM(COUNTIFS(raw[week1],refToWeekNumberCell,raw[status],{"Success","Try again","Fail","Invalid"}))
..so I'm looking to count how many "Invalid" or "Valid" (all the other statuses) I have at any given week. If the status is "Invalid" there will only ever be one attempt. So checking against the column "Week 1" is enough. If I however want to check number of "Valid attempts", I will need to check against both the "Week1" and "Week2" column.. Can this be done somehow? Do I need a helper column, and if so, how do I formulate that one?
Sample data:
Raw table:
Week1
Week2
Status
7
7
Success
7
-
Success
7
-
Invalid
7
8
Success
7
8
Success
8
8
Success
Table seems to look good in preview, but not when posted, so:
Expected result: Count of Week 8 that are not Invalid either in column "Week 1" OR "Week2". Since Invalid always only have anything under "Week 1" then that is easy. But on row 5, the logic fails as I can only use one column as the range..
If it doesn't get much more complicated than two columns, you could use:
=SUM(IF((A2:A7=8)+(B2:B7=8)>=1,1,0)*(C2:C7<>"Invalid"))
The "+" is typically used to act as some sort of "Or" validation inside such boolean-structures. However, if you have more columns, the MMULT() variant is much easier to maintain.
=SUM(--(MMULT((A2:B7=8)*(C2:C7<>"Invalid"),{1,1})>0))
As you are using Excel365 then try-
=COUNTA(FILTER(C2:C7,MMULT((A2:B7=8)*(C2:C7<>"Invalid"),SEQUENCE(COLUMNS(A2:B2)))))
I can't upload the picture don't have enough points but this is the link Pic
I used this formula
=IF(E43>12,"1","0.5")
The thing is I'm trying to make this IF function work...
I'd like it to do this
if in E43 says 0.1-11.59 to write in F43 0.5,
if in E43 says 12-23.59 to write in F43 1,
if in E43 says 24-47.59 to write in F43 2... etc.
In E43 is hours I got everything else sorted but this is a problem...
This is probably the most straight forward answer, but it can get tedious to type out. Don't forget to set it greater or EQUAL to or less than or EQUAL to or your statement will fail at the low and high ranges. Set F43 equal to this... =IF(AND(11.59>=E43,E43>=0.1),0.5,IF(AND(23.59>=E43,E43>=12),1,IF(AND(47.59>=E43,E43>=L24),2,"Greater than 47")))
There are a few ways you can do this. If the value in F43 is uniformly based on E43, you could use a formula like
=CEILING(E43/23.999,0.5)
But if the value in F43 isn't uniform (like your example of 24-47.59 = 2) then you can either:
1)
Write a long nested if statement with several AND() functions (i.e. AND(E43>=24,E43<=47.59), or
2)
write a table of vlookup values i.e.
0 | 0.5
12 | 1
24 | 2
and the formula
=VLOOKUP(C7,$C$12:$D$14,2,TRUE)
How to use a conditional operator in a custom number format for dates and times in Excel?
If I have a column of numbers, I can use a custom number format to display a singular or plural word.
Right click cell > Format Cells... > Number > Category: Custom > Type:
[=1]# "item";# "items"
> OK
For a cell containing 1, the custom number format displays "1 item".
For a cell containing 7, the custom number format displays "7 items".
Likewise, I want to do the same with time.
If I have a column of times, such as 00:01:00, 00:20:00, 00:25:00, etc., I want to display "1 minute", "20 minutes", "25 minutes", etc.
I first tried [=1][m] "minute";[m] "minutes", but it turns out that 1 means 24 hours or 1 day.
The value of 1 minute is
1 / 24 / 60 = 1 / 1440 = 0.0006944444444444444444444444...
I tried entering a fraction, but the [=1/1440] in [=1/1440][m] "minute";[m] "minutes" turns into [=1].
Unfortunately, I tried [=0.000694444444444444][m] "minute";[m] "minutes", but that does not work.
The following works, but I want to use an exact minute value.
[<=0.000694444444444445][m] "minute";[m] "minutes"
Is there a format for 1 minute that works?
Here is the documentation on the custom number format:
Create or delete a custom number format:
http://office.microsoft.com/en-us/excel-help/create-or-delete-a-custom-number-format-HA102749035.aspx
Interesting question. At first sight, trying this fraction format:
[=0 1/1440][m] "minute";[m] "minutes"
seems to work. After entering it you will see, however, that this displays the same decimal as in the post. This is ok for the current session, but saving the file and reopening reverts to the original problem again.
The issue is that values in number formats are rounded to 15 digit precision, whereas 17 digits are needed to specify the internal floating points numbers exactly. One way to see this is to try this 17 digit precision test from the immediate window:
?[0 1/1440]=0.00069444444444444444
This returns True but removing the last two 4s so there are only 15 digits of precison returns False.
Given these observations, I think the only reliable way is to enter the 15 digit interval containing the decimal value equivalent to one minute. This can be done using the following number format:
[>0.000694444444444445][m] "minutes";[>0.000694444444444444][m] "minute";[m] "minutes"
(or if seconds were included the first value could be replace by the 2 minute value i.e. 0.00138888888888888)
An alternative method is to use conditional formatting which would probably be simpler. First apply the default number format [m] "minutes" to the cell. Then from the ribbon select Conditional Formatting > New Rule > Use a Formula... with the options: Formula...: =MINUTE(A1)=1 NumberFormat: [m] "minute"
I have an Excel 2010 workbook which contains a cell with the value of, say, 9876:54:32 (manually entered) representing 9876 hours, 54 minutes and 32 seconds of, say, phone talk time.
Then I have a cell with the value of, say, 1000 (manually entered) representing 1000 calls.
I want to divide the values to get the average talk time of 592.615 minutes per call.
I'm doing a regular =A1/B1 and it gives me an error.
* EDITED *
Thanks Brain Webster for correcting my math. I mean 9.876 hours. But the point is that Excel gives me an error, not my manual math. Playing around with it I discovered that Excel is fine with me with values up to 9999:59:59. Once I try with 10000:00:00 and up, it doesn't recognize it as a time value.
I love these seemingly easy riddles, so here is my solution as a formula and as a VBA attempt:
my original:
= (LINKS(A38;FINDEN(":";A38)-1)/24)+ZEITWERT("0"&RECHTS(A38;LĂ„NGE(A38)-FINDEN(":";A38)+1))
translated:
= (LEFT(A38,FIND(":",A38)-1)/24)+TIMEVALUE("0"&RIGHT(A38,LEN(A38)-FIND(":",A38)+1))
This will get you the right value to a given 10k text of a time duration. You would only have to setup the format of the cell to [h]:mm:ss. Then those values will look the same, but one would be a string and the other a number - and that is a major difference ;)
In vba it looks much more easier, and once defined, you can use it as a worksheetfunction.
Public Function GetDurationValue(ByVal strInput As String) As Double
Dim arrResult As Variant
arrResult = Split(strInput, ":") 'saves you parsing
GetDurationValue = (arrResult(0) / 24) + _
TimeSerial(0, arrResult(1), arrResult(2))
End Function
A38 = "10971:12:14"
=GetDurationValue(A38)
=457.13349537037
You can use LEFT and RIGHT function to retreive parts of the time value and then sum and multiply these values by 60 [minutes] (resp. 3600 [hours]).
Something like this for the hours, minutes, seconds (A1 is the cell with time value):
B1=VALUE(LEFT(A1;FIND(":";A1)))*3600
B2=VALUE(LEFT(A1;FIND(":";A1; FIND(":";A1))))*60
B3=VALUE(LEFT(A1;FIND(":";A1; FIND(":";A1; FIND(":";A1)))))
Now you can sum that:
C1=SUM(B1;B2;B3)
Then divede by calls count (A2 is the cell with the calls count):
D1=C1/A2
Finally format it like time:
E1=TEXT(D1/(24*3600);"d \day\s hh:mm:ss")
BTW: I tried that in Excel 2013 and when I enter 111:22:33 into a cell it automatically converts to a time. So then I can divide it like you try...
It appears that hours > 10000 are not recognised as such by Excel. Therefore we need to introduce an IF() to see whether this is the case and determined the alternative formula for the case where hours >10000
=IF(ISERROR(FIND(":",A2)),A2/B2, <SCRIPT IN CASE OF >10000>)
<SCRIPT IN CASE OF >10000> will now be:
VALUE(LEFT(A2,FIND(":",A2)))/24+VALUE(LEFT(A2,FIND(":",A2, FIND(":",A2))))/(24*60)+VALUE(LEFT(A2,FIND(":",A2, FIND(":",A2,FIND(":",A2)))))*(24*60*60)
combine and enjoy!
Assuming you don't exceed 100,000 hours in A1, and you always display hours, minutes and seconds then this formula should suffice
=IFERROR(A1/B1,(LEFT(A1)*10000/24+RIGHT(A1,10))/B1)
format result cell as [h]:mm:ss to get the result as a time value
With 10971:12:14 in A1 and 1000 in B1 that should give a result of 10:58:16 [or format result cell as [m]:ss to get minutes and seconds like 658:16]
This version will work with any number of hours and with or without seconds
=IFERROR(A1/B1,(LEFT(A1,FIND(":",A1)-1)/24+RIGHT(A1&IF(COUNTIF(A1,":*:"),"",":00"),5)/60)/B1)