Hey guys I have a situation where I need to format a column to display APR(%) values in a certain way. Basically the values should be formatted like below:
Raw input Formatted value
========= ===============
0 0
0.0 0
4.4566 4.5
5.00 5
6 6
6.4 6.4
I tried creating this formula below but for some reason it doesn't round the number to 2 decimal places.
=INT(ROUND(A1,1)*100)/100
What am I doing wrong? Or is there a better way to handle this?
UPDATE: So I am applying the function to the same cell as the number is in. For instance the A1 cell contains 4.566 value and I applied the function to that same cell and this doesn't seem to be working for Excel. Any other ways to do this?
P.S: Im using the MS Excel for Mac
Two steps
Format the cells to Number with one decimal place
Conditionally format the cells to a Number Format of General if the value is an integer
EDIT: Since you cannot conditionally format the number format in Excel for MAC, there are several workarounds.
If you do not mind changing the actual value, add a column which you will use to display the result. Format the Column as "General", and use this formula (assuming your "real data" is in column A:
=IF(A1<>INT(A1),ROUND(A1,1),A1)
Other options that may work would include using an event-triggered macro (if that can be done in Excel for Mac); and possibly you can create the worksheet in Excel for Windows and the conditional format might be recognized in Excel for Mac, even if you can't create it there.
As explained in the documentation here,
Suppose that cell A1 contains 823.7825.
...
=ROUND(A1,2) ... equals 823.78
You should be able to therefore apply this to your entire column to get the precision that you are after.
Rather than using =INT(<another_cell_value>*100)/100 to derive the format you want, simply specify a custom format with the following:
#,###.##
This way, you only get the number of decimal places that you specified in the ROUND function.
Related
=SUMIF(E3:E,"YES",C3:C)
The above formula works in adding the numbers in C if the corresponding E cell is "YES", however my cells in C have "# MINS" in them, is there a way to make SumIf ignore words and only add the number?
SCREENSHOT OF SPREADSHEET: https://cdn.discordapp.com/attachments/358381825246101505/488443165364322327/Screenshot_1.png
If you’re using Google Spreadsheets, you have the possibility to format the numbers as you want.
In the cells, store the numbers only so that SUMIF will work, then create a custom number format: in the toolbar - Format - Number - More Formats - Custom number format - type in # “MINS”.
=SUMPRODUCT(LEFT(C3:C5,LEN(C3:C5)-LEN(" mins"))*(D3:D5="yes"))
This is an array like calculation. As such full column references may bog your computer down with excess calculations.
Get rid of the MINS. You can use Find & Replace or Text to Columns, etc.
Create a custom number format of 0 \M\I\N\S.
Use your original formula.
excel
=SUMIF(E:E,"YES",C:C)
google-spreadsheet
=SUMIF(E3:E,"YES",C3:C)
Shareable link
I want to convert the numbers from text format to numbers so tha i can make the average or sum of the whole columns.
I tried all the possible ways asfar as i read in many blogs, but nothing works.
There is no Green mark on the cell nor a quote '
Tried copying an empty cell and select required cells and paste special methods also.
It looks like you are using a French version of Excel. In this case a number should be 6,04 and not 6.04
Do a find and replace of . for , and you should be able to change the format to a number if it is not done automatically.
You can either:
change the values to numbers
use a formula that can handle text-type numeric values
Say we have data in column A that is Text. This formula:
=SUMPRODUCT(--(A:A))
can give you the sum without having to convert first:
I want to ask a very simple and maybe for some it may sound silly.
One person told that while copying and pasting in Excel you should use Paste Special and paste formats first and then values, then it keeps any leading zeros or else they will be removed. But someone else told other way round i.e. first values and then formats. I didn't notice any change also if I pasted as it is after copying.
So please tell me if these people are true and if yes which exactly is the correct order?
Oh, the joy of Excel conversions. You have to be cautious with your different circumstances.
Time to have some fun. Try this:
In cell A1 format the data as Text and enter the value 010.
In cell A2 leave the format as general and enter as 010.
Now go to the immediate window in VBIDE and execute the following:
? Typename(Range("A1").Value)
? Typename(Range("A2").Value)
A1 is a string, and A2 is a double.
If you change the format of A1 now to General then again type:
? Typename(Range("A1").Value)
It is still string - AND it still has the leading 0 at the front!
HOWEVER: now execute the following:
range("A1").Value = range("A1").Value
Although this looks like a pointless command - its effectively updates the cell by using VBA. Excel will now do the conversion to a double!!
? Typename(Range("A1").Value)
This is now a double.
So altering the format after the data can result in different data because Excel is doing a clever conversion. But this is dependant on the cell being updated. Just changing the cell format might change that value, but not necessarily - and later it could change if a user presses F2 and enter on the cell. Lovely - thank you excel for being intelligent.
Don't even get me started with other conversions.
So, I suggest that in the majority of cases, you should actually format first and data after.
Happy pasting! :)
Cell value and cell format are two distinct properties of a cell in Excel.
For displaying values, excel applies the format of the cell to its value. So if your cell holds a number and the format specifies that the number should have leading zeros, the number will be displayed with a leading zero. This does not change the underlying value!
The format affects only the display.
As an example:
Let's say your cell holds the value 5.5 as numerical value. Applying the format 0.00 will display that value as 5.50. Applying the format 0.00 min will display the same value as 5.50 min. But the value itself is still unchanged 5.5 - this way, you can e.g. be very specific about how you want to display a number, but still use its plain value for calculations. Same principles apply to every other formatting rule and data type of course.
So no matter which way round you paste - as long as the cells end up with the correct combination of value and format, you will end up with the correct result.
I have an Excel spreadsheet with a range of values which are numbers that go to up 20 decimal places, unpivoted from another sheet using the trick from here.
The trouble is the cells are only displaying 10 digits so, for example, even though the value is 5.46827166811115 it is showing as 5.468271668.
I've tried setting the format to text but it still wants to treat it as a number, the number of decimal places varies so I can't use a fixed #.### format. The only way I can get it to show is to format the cells as text and to just select and then click in the entry box for each and every cell!
It then shows a warning that the number in the cell is formatted as text or preceded by an apostrophe but at least it's showing the full value.
I did find a VBA script that just did something stupidly simple like cell.Value = cell.Value for the selection which seemed to work but I can't find it anymore and I can't reproduce that now.
Surely there's an easier way to do this? It wouldn't matter so much but when I import this data through SSIS into a VARCHAR(MAX) it's getting the truncated values!
Pre-pend a single apostrophe ' to the data. In many cases, this is more effective than setting the cell format to text.
You could format the cell as text and the do an .AutoFit so the cell expands to show all the cell content, like this:
Columns("A:A").EntireColumn.AutoFit
that will expand the A:A cell so all its content is visible.
try formatting with #.000 instead of #.###, but if your problem is that Excel is dropping precision on you, you could try multiplying the value by 10^20, then dividing by 10^20 on the SQL side.
found more info:
here
looks like Excel is limited to 15 digits of precision, multiplying by 10^20 doesn't increase the precision, so you can treat it like text or split the remaining digits into another column and combine them back with SSIS or SQL.
Have you added the IMEX=1 to your connection string? That keeps SSIS from trying to figure out the data from the first few rows.
Also, what about using a decimal datatype instead of varchar(max)
I am reading the excel sheet from C# by using interop services. My sheet has one of cell value as 0.00. but run time when I am checking the value of that cell in C# code I am getting "1.845E-07" this value. When I check in excel sheet, on that cell right clicked , say format cell I got "1.845E-07" value in sample section. How to get exact value?
Please help me. The code is huge, so I can't provide it here.
that line is:
if (Convert.ToString(((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2) != string.Empty)
{
drRow[dtSourceEXLData.Columns[constants.Floor]] = ((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2.ToString();
}
Same problem with Date cells "39448". what does this means??please help....
1.84E-07 is the exact value, represented using scientific notation, also known as exponential notation.
1.845E-07 is the same as 0.0000001845. Excel will display a number very close to 0 as 0, unless you modify the formatting of the cell to display more decimals.
C# however will get the actual value from the cell. The ToString method use the e-notation when converting small numbers to a string.
You can specify a format string if you don't want to use the e-notation.
Highlight the cells, format cells, select Custom then select zero.