Excel if formula possibility - excel

I have an issue that I don't personally know how to format. I need to subtract numbers that are in seconds, formatted to be viewed as 58.43 or 59.99, but that are sometimes in minutes, formatted as 1:01.33 for example.
I would also need to be able to subtract the numbers from each other to be recognized as (+1.08) or (-0.78), with the parentheses.
I'm sure I can elaborate somewhere, so let me know if this doesn't make any sense. Thanks

It depends if 58.43 is formatted as a number or time. Date and time are stored in number of days, so the time 58.43 is actually stored as the number 0.00067627314814814800000 (58.43/24/60/60).
If both values are time values, then the custom number format of the result can be:
(+s.00);(-s.00);(0.00);#
To handle both cases, instead of =A1-A2 you can try this something like this:
=IF(A1<1,A1,A1/86400)-IF(A2<1,A2,A2/86400)

If those are just time values formatted as mm.ss then you can use TIMEDIFF()
https://support.office.com/en-us/article/Calculate-the-difference-between-two-times-e1c78778-749b-49a3-b13e-737715505ff6
If not, try to convert them to time values and than use TIMEDIFF()

The first part is straightforward
Apply a default format of
ss:00
Then in conditional formatting use a formula
=A2>=TIME(0,1,0)
and apply a format of
m:ss.00
for the ones that are a minute or more.
There is no direct solution to the problem of displaying negative times short of changing the default date system used by Excel as you can see in a number of references. The only way to do it here is to test whether the result is positive or negative and display the positive difference with or without a minus sign.
=IF(B2>=A2,TEXT(B2-A2,"(+s.00)"),TEXT(A2-B2,"(-s.00)"))
The downside of this is that they are actually text values and you can't use them in any further calculations. However the results of A2-B2 are still good even if you can't display them directly, so you can use A2-B2 in subsequent formulae if you want to even if it is negative.

Related

finding time difference with 1 cell

I recently pulled a huge amount of data into a csv file, as a result a large amount of data is being formatted like this:
xx:xx-xx:xx - 'text'
The problem i'm having is this is all in one cell, I've tried looking online without much luck so basically wanted to know if it's even possible to find the time difference between xx:xx-xx:xx even if they're stored on the same cell? If not, is there a way to split these times into different cells en mass?
edit:
I've managed to remove the text from the cell, I now am left with 1 cell containing ranges similar to:
Please try, formatted as Time:
=MID(A1,7,5)-LEFT(A1,5)
If that does not work then check for leading spaces. Won't suit if times are late/early order, nor if spanning midnight.
Edited so there should be no need to strip out 'text'.

Protecting TIMEVALUE usage inside SUMPRODUCT from input errors

First question here, thanks in advance for your patience and assistance!
I have a spreadsheet that contains course types (column A, e.g. "Lec" or "Dis"), enrollment numbers (column B, as integers), and session times (column C, string time interval e.g. "10:00AM - 01:00PM").
I need to sum the enrollment numbers for all classes of a certain type (say "Lec") that end before a certain time (say 3:00 PM). The following code accomplishes that:
=SUMPRODUCT(--((A2:A8="Lec")), --(TIMEVALUE(MID(B2:B8,11,5)&" "&MID(B2:B8,16,2))<=TIMEVALUE("03:00 PM")), C2:C8)
The problem is that some of the session times may be blank, which renders a "#VALUE!" error. As best I can tell this is because TIMEVALUE is unable to accept an empty cell as input, so whenever that occurs it breaks the whole thing. I therefore need in this case for the formula to ignore the row and not progress to the various other evaluations.
I have attempted to protect the TIMEVALUE content behind various conditional statements, e.g. only considering that row if the time session length is correct (length=17). I have not been able to do this successfully, however. Nor have my internet searches found a similar-enough situation to use for help.
Because of the circumstances around this project, I am strongly interested in formula solutions before considering things like changing the overall spreadsheet format or adding dummy columns for computations. That said, I welcome any and all suggestions!
Unfortunately, using AGGREGATE as SUM does not skip errors if there is a Calculation in the formula. Similarly, IFERROR and ISERROR only work properly with Ranges/Arrays when in an Array Formula, not when in SUMPRODUCT. That's the easiest options out unless you want a calculation column.
However, all is not lost! First, we reduce your SUMPRODUCT to a single argument with * in place of ,:
=SUMPRODUCT(--(A2:A8="Lec")*--(TIMEVALUE(MID(B2:B8,11,5)&" "&MID(B2:B8,16,2))<=TIMEVALUE("03:00 PM"))*C2:C8)
Next, we change this from =SUMPRODUCT(X) to =SUM(IFERROR(X,0)):
=SUM(IFERROR(--(A2:A8="Lec")*--(TIMEVALUE(MID(B2:B8,11,5)&" "&MID(B2:B8,16,2))<=TIMEVALUE("03:00 PM"))*C2:C8),0)
Just remember to press [Ctrl]+[Shift]+[Enter] instead of just [Enter] to convert to an Array Formula - the formula will display in {Curly brackets}

Using ROUND after Nested IF Statements in Excel

I am working on a spreadsheet for a client that calculates values and shows them as fractions after a good amount of deductions. We were running some test after I had it all set and ready and they ran a certain number through the spread sheet. I'll try to beak it down as easily as possible (any value with brackets is user input. So Width is [94.5(94 1/2)] that number get subtracted by 7.5312(7 17/32 that equals 86.9688(86 31/32) that number is then divided by [3] which then equals 28.9896(28 95/96) This is where the problem is though. 95/96 is not a "real" fraction is there a way I can round numbers like this down to 64ths? They were expecting 63/64ths Even though the math is correct they need it to round down in those cases.
The If statement is this:
=IF(E4=1,(K4-F19)/1,IF(E4=2,(K4-G19)/2,IF(E4=3,(K4-H19)/3,IF(E4=4,(K4-I19)/4,IF(E4=5,(K4-J19)/5,IF(E4=6,(K4-K19)/6,IF(E4=7,(K4-L19)/7,IF(E4=8,(K4-M19)/8,IF(E4=9,(K4-N19)/9,IF(E4=10,(K4-O19)/10,0))))))))))
This is a single part of the IF statement:
=IF(E4=1,(K4-F19)/1
Is there a way around this or are they SOL(Sorta Outta Luck)?
Thanks for any insight.
Assuming in A1, please try:
=ROUNDDOWN(A1*64,0)/64
with suitable formatting.
This ensures that all results are multiples of 1/64.

Why do Excel values in parentheses become negative values?

A colleague and I encountered a behavior in Excel which isn't clear to us.
Background:
We have a tool which converts an Excel sheet into a table format. The tool calculates the formulas which are in excel and replaces variables inside it with specific values.
The excel tool is used by one of our customers who use values like (8) or (247).
These Value are automatically translated by excel to -8 or -247.
Question:
I saw that many people want to display negative numbers in parentheses. But why would Excel change values in parentheses to a negative number?
I know that I could simply change the cell config to text and this would solve the problem but I wonder if there is a reason for the behavior, since there seems to be no mathematical reason for this.
Its simply the different format of cells you are bringing the "values from" and "pasting to". ..... numbers with parentheses are in cells with "accounting" format and negatives are stored in general or standard number formated cells. To resolve you can change the format of destination cells to accounting using cell formatting as number>accounting.
To answer the why, it's because accountants put negative numbers in brackets for readability
Unfortunately, this is one of the excel feature/bugs that helps some folks and frustrates others. When opening a file or pasting content, excel will immediately and always try to parse any values into formats it deems appropriate, which can mess up data like:
Zip Codes / Tel. # → Numeric: 05401 → 5401
Fractions → Dates: 11/20 → Nov, 20th YYYY
Std. Errors → Negative Numbers: (0.1) → -0.1
For some workarounds , see Stop Excel from automatically converting certain text values to dates
Once the file is open/pasted, the damage is already done. At that point, your best bet is:
Updating the field and displaying as text (appending with ') to prevent re-casting
Formatting the field if the operation wasn't lossy and is just presenting the info differently
Running a clean if/else to pad or other convert your data based on the identified errors
Specific to displaying values back in parens, if excel is converting them and treating them like negative numbers (which may or may not be the appropriate way to actually store the data), you can apply a different format to positive and negative numbers to wrap back in parens.
It is standard practice to write negative values as numbers in parentheses, especially in accounting. This makes negative values stand out much more than a simple negative hyphen; compare -1 and (1).
Excel is a tool very commonly used by accountants and supports accountant-style spreadsheets. Therefore, entering (100) means having a value of -100, even if there is no minus hyphen!
Here is a fun fact, if you enter (-10), Excel will treat it as normal text.

How Can I convert Exponential form back to a number?

I am trying to convert exponential form to a number but I can't figure out how it has to be done.
I have a number 1820674000000385406.
I am pasting this number excel after saving this I am following these steps
Format cells->Number and selecting the type.
but after doing this I am not getting my original number I am getting the number as 1820674000000380000
but I want my original number back. Please help me with this.
Excel has a limited resolution of 15 digits for the this type as you can see here:
Excel specifications and limits
Thus Excel saves 182067400000038E+04, which are the 15 first digits of your number and the corresponding exponential.
If you want to keep your number as it is, I recommend you to use a database instead. Excel is not made for these kind of huge numbers.
Best
While storing you can app ' before the number. This would stop excel from converting the number.
Example - 1820674000000385406 would be stored as '1820674000000385406
Another work around is to store number as text. By formatting the cells as to type text.
More details you can find here

Resources