Excel Remove Decimal Places - excel

I have an excel formula that is producing a lot of decimal places and I cannot reduce them using the format cell -> numbers -> decimal places options. Here is the formula.
Cell named V01_MIN
V01_MIN =MIN(6:6)
Has a value of 2
Cell named V01_MAX
V01_MAX =MAX(6:6)
Has a value of 1800
Cell named V01_A
V01_A =1-V01_MIN*V01_B
Has a value of 0.889877642
Cell named V01_B
V01_B =99/(V01_MAX-V01_MIN)
Has a value of 0.055061179
X6=723
X7=V01_A+V01_B*X6 (value of 40.69911012)
X8=1
X9=X7*X8 (value of 40.69911012)
X10=1
X11=X9*X10 (value of 40.69911012)
X13==CONCATENATE(X12,", ",X11)
The final results of X13 are:
V01, 1162, 40.6991101223582
I want them to be:
V01, 1162, 40.7
I'm trying to figure out how to make this happen. I've already tried changing the cell formatting on all of these cells (including the final cell) to one decimal palce and that didn't work.

Cell formatting and the actual number in the cell are two different things.
The cell formatting merely changes how the number is shown to you in the cell.
The actual number in the cell will still keep all precision of the number.
If you wish to have the last number rounded, consider this:
X13=CONCATENATE(X12,", ",ROUND(X11,1))
This will round the result in X11 to 1 decimal place before concatenating.

By concatenating you are changing your data to text instead of a number and the number formats won't effect it. Generally you have two options
Either round within you concatenate function
X13==CONCATENATE(X12,", ",roound(X11,1))
or change it back to a number (easiest way is multiply by 1): Note this won't work in your case since you are joining text strings and variables but is useful to be aware of.
X13==CONCATENATE(X12,", ",X11)*1
and then you can format based on decimal places.

Related

Excel custom formatting numbers (0 especially)

Based on this comment fom SoftTimur I did some testing on formatting and came across the following problem:
If I put =SEQUENCE(4,,-2) in A1 and custom format the range with 0;-0; it'll show the values as I intended.
If I sum the spill range in A6 using =SUM(A1#) it shows the correct value (-2).
If I put the following in B1: =TEXT(SEQUENCE(4,,-2),"0;-0;") I expected the same result as above. However Excel sees it as text (by default aligned to the left).
If I sum the spill range in B6 using =SUM(B1#) it shows the result 0 while if I sum B1+B2 I get a correct result.
Question 1: What's the explanation of the incorrect sum result in B6 versus the correct one in B7?
Question 2: Is there a different way to display a zero as blank, but keep the ability to calculate the range containing that value?
Question 1:
The TEXT function returns text and computers can't add text strings together. They can only add numbers together.
Excel will sometimes automatically perform type conversions to allow formulas to deliver what Excel guesses as being the expected result. In this case, it is sometimes turning text into numbers before adding them together. This can make like easier for users but the inconsistency can easily lead to errors.
Say A1 and A2 are formatted as text and contain the text character "1". Excel will do an implicit type conversion for operators (+-*/):
=A1 + A2
It won't do conversion for ranges in functions:
=SUM(A1:A2)
=SUM(A1,A2)
When taking in a range, the SUM function will ignore all text, so that it can still sum the numbers in the range without throwing an error. If all cells in the range contain text it will return 0.
However if you tried to use the addition operator on two cells containing text that can't be converted to numbers, it will throw an error.
Note that when you put "A1 + A2" inside the SUM function, excel first evaluates the addition operation (as this is a single input within the function which must be evaluated first), so it converts A1 and A2 to numbers at this point to create a single numeric result, and then the SUM function takes just the single numeric value as input and returns it again as the total.
If you use SUM with two separate inputs, as =SUM(A1,A2), it doesn't convert either input to a number first.
Question 2:
To get the correct result using the SUM function over the range, you can modify the original sequence formula so that it is delivering numeric values. This can be done in various ways:
1 - Convert the text back to a number by multiplying by 1 (forcing another implicit type conversion), handling the error generated for the nullstring which can't be converted to a number:
=IFERROR(TEXT(SEQUENCE(4,,-2),"0;-0;")*1,"")
2 - Test for 0 using an IF statement and return the null string:
=IF(SEQUENCE(4,,-2)<>0,SEQUENCE(4,,-2),"")
3 - Invert the sequence twice, which throws an error only when it is equal to 0:
=IFERROR(1/(1/SEQUENCE(4,,-2)),"")
OR you can modify the SUM formula to convert the range to numbers on input:
=SUM(IFERROR(B1#*1,0))
However this approach requires you to modify all formulas that look at the original sequence. If the original sequence is intended to be used as numbers (as it is in this case), it is better to have it be generated as numbers in the first place.

Formating doesn't work when using a formula on a cell

Example:
I am using the formula:
=IMDIV(F3,0.7)
f3 value = 37.44, so the result on the formula cell = 53.9948890...
I need to turn the 53.9948890... into a dollar value, so I want to show it like $53.99
AT THE END I JUST WANT THE DOLLAR VALUE WITHOUT ANY FORMULAS.
How can I format the results of the formula into dollar value?
I tried to highlight the cells and change the formatting but it DIDN'T WORK.
I tried to copy and paste just the numerical values and then formatting the cells, and it DIDN'T WORK.
If I type the number and then I try formatting the cell, then IT WORKS, but then I need to do it manually for hundreds of lines..
You can use DOLLAR but this returns text again which means you cannot input this into mathematical comparisons/functions as is.
=DOLLAR(IMDIV(F3,0.7))
I would recommend using ROUND instead to convert your output to be numeric and then just format the column as currency. Then you have numeric outputs that you can actually feed into functions or compare
=ROUND(IMDIV(F3,0.7),2)
The real question is why are you using IMDIV in the first place? As you have discovered, that method will require some downstream work to format to number/currency. Since you are just supplying real numbers, you don't really use the 'special sauce' that is added to the IMDIV function. You are just taking extra steps to do a standard division.
i.e. (37.44 + 0i) / (0.7 + 0i) = 37.44/0.7 so why not just use F3/.7?
As you can see in below photo, both outputs return the same number. The only difference is the IMDIV function returns this value as string which has to be converted before later use.

Excel: adding multiple h:mm:ss cells

I am attempting to add three cells which I have formatted as hh:mm:ss
and it is giving me incorrect sum as one of them is missing hh
A B c
01:01:01 :01:01 01:01:01 SUM(A,B,C)
is returning 2:02:02 when it should be 2:03:03
I have several cells missing the HH so it is throwing off all my formulas, any way I can force the 00:01:01, on a cell that is :01:01?
Try,
=SUMPRODUCT(TIMEVALUE(RIGHT("00:00"&TEXT(A2:C2, "[hh]:mm:ss;#"), 8)))
The format mask used by the TEXT function (hh:mm:ss;#) converts real time values to text-that-looks-like-time and leaves values that are already text-that-looks-like-time unchanged. Leading zeroes and a colon are concatenated onto the result as a prefix and the right-most eight characters are parsed off with the RIGHT function. This should cover both :00:00 and :00 text values. This allows the TIMEVALUE function to process the resulting text to a true time value. The SUMPRODUCT wrapper produces cyclic calculation so that you don't have to sum three largely redundant formulas.
In the following sample image, note the default left alignment of B2 indicating text while A2 and C2 are right aligned indicating a true number, date or time.
If the values will always be contiguous as you show, you can try:
=SUMPRODUCT(--("00"&A1:C1))
Prepending "00" and the double unary will have no affect on the real time values, but will convert the "missing hour" value to a real time

using array formula to average if

i have some cells d1:d10. Some have numbers, others contain "". The "" is the result of an =iferror(,"") function to leave a blank cell.
I am trying to average d1:d10 but only including the cells that are not "".
I have =AVERAGE(IF(D12:D51<>"",D12:D51)) followed by ctrl+shft+enter but it is still taking the average of all the cells (essentially taking the sum and dividing by 10, where I want it to take the sum and divide by less than 10 depending on the number of "" cells)
I couldn't reproduce your problem in Excel 2013.
Normally, Excel's average function ignores text, empty cells and logical values. So, the following formula should do what you are trying to do.
=AVERAGE(D1:D10)
The if clause in your function returns either some numbers or FALSE. Again, normally, Excel's average function ignores FALSE values so it shouldn't behave like you said. If it somehow is converting boolean values to numeric values based on Excel's version (FALSE to zero) you can just give a string instead of a boolean value so it has to ignore those values:
=AVERAGE(IF(D1:D10<>"", D1:D10, "s"))
Alternatively you can calculate the average without the average function:
=SUM(IF(D1:D10<>"", D1:D10))/COUNT(IF(D1:D10<>"", D1:D10))

Excel 2007 Duplicate Check Wrongly Converting Hex as Exponent

I have a spreadsheet used to verify a long list of 8-digit hexadecimal numbers for duplicates.
It has two columns - one for the hexadecimal values and another where the following formula is used to check for duplicates (given that this second column is column B):
=COUNTIF($B:$B, B1)
This has worked fine for most numbers except for these values:
69000700 and 690007E2.
The first column is formatted as text, however it seems that the COUNTIF function is doing some kind of unwanted implicit cast of my hex value, and taking the second hex value as an exponent (which would make it the same as the first value).
It also doesn't seem to matter what format my hex column is - the COUNTIF function always interprets these values as numbers and therefore they appear as duplicates.
Is there a way to ensure the COUNTIF function takes these cell values as string parameters without doing an implicit cast?
Maybe it's feasible to add an extra column with a formula
=CHAR(34) & B1 & CHAR(34)
copied down.
The formula encloses the text into quotes, and "690007E2" will no longer be interpreted as "69000700" (Excel 2003).

Resources