logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Tom Van Overbeke  
#1 Posted : Saturday, November 16, 2019 5:29:28 PM(UTC)
Tom Van Overbeke

Rank: Member

Groups: Registered
Joined: 10/23/2019(UTC)
Posts: 11
Belgium

Hello,

I have a calculated field displaying as a numeric, with occurrences like 9.999999997
I'd like to always have 2 decimals.
From what I learned in this forum, the best way to do this is using the cell script for this field.

But I can't seem to get the syntax right. Can someone show me how I can reformat the output to a 2 decimal numeric please?

Thanks a lot,
Tom
Tom Van Overbeke  
#2 Posted : Sunday, November 17, 2019 9:42:04 AM(UTC)
Tom Van Overbeke

Rank: Member

Groups: Registered
Joined: 10/23/2019(UTC)
Posts: 11
Belgium

Hello,

I've found the answer myself, so for everything else who needs this:

cell.Value = (Convert.ToDouble(cell.Value)).ToString("#.##");
epf  
#3 Posted : Monday, November 18, 2019 7:00:28 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Normally you do not need to use CellScript...
Just set the 'Format' property to 'Numeric 2 Decimals'
Tom Van Overbeke  
#4 Posted : Monday, November 18, 2019 1:44:54 PM(UTC)
Tom Van Overbeke

Rank: Member

Groups: Registered
Joined: 10/23/2019(UTC)
Posts: 11
Belgium

Thanks,

This does not seem to work when using excel files for a source.
epf  
#5 Posted : Tuesday, November 19, 2019 10:12:56 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
probably because some cells have text in the Excel sheet, so the ODBC driver returns the data as text instead of numeric...
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.