Skip to main content
Solved

How to RoundUp or RoundDown Decimal

  • August 16, 2019
  • 2 replies
  • 34 views

Dear TimeXtender's Team,

What is choice to setting rounding in TimeXtender if we want to set up decimal ? 

Like example .. 
in Original Data is $12,3456, we just want the result is $12,34 (2 decimal)

because in TX, it will be $12,35

Thank you,

Best answer by JTreadwell

Hi Ghazy, Thanks for posting this question. This is a very common problem with a straightforward solution. I would solve this by doing the following in TimeXtender.

I have a sales transaction table with a field called Sales Amount. 

In my example, I created two additional fields. The first is named SalesAmount(NoDecimal) where I have edited the field and reduced the fractional digits to zero. 

I added a custom transformation to this field. 

Next, I added another field with the same, zero fractional digits, called SalesAmount(Floor). 

This time I added a transformation but used the FLOOR function. As you can see in the snip below I am using FLOOR() with the field I want to round down in the parenthesis. See here for more info on using FLOOR.

So my fields appear like this

And Finally, the data appears like this: 

 

Hope that helps!

2 replies

Forum|alt.badge.img
  • Participant
  • 47 replies
  • August 16, 2019

To round down (truncate) you can use the third argument of the ROUND function.

https://docs.microsoft.com/en-us/sql/t-sql/functions/round-transact-sql?view=sql-server-2017#c-using-round-to-truncate


JTreadwell
Employee
Forum|alt.badge.img+5
  • Employee
  • 182 replies
  • Answer
  • August 16, 2019

Hi Ghazy, Thanks for posting this question. This is a very common problem with a straightforward solution. I would solve this by doing the following in TimeXtender.

I have a sales transaction table with a field called Sales Amount. 

In my example, I created two additional fields. The first is named SalesAmount(NoDecimal) where I have edited the field and reduced the fractional digits to zero. 

I added a custom transformation to this field. 

Next, I added another field with the same, zero fractional digits, called SalesAmount(Floor). 

This time I added a transformation but used the FLOOR function. As you can see in the snip below I am using FLOOR() with the field I want to round down in the parenthesis. See here for more info on using FLOOR.

So my fields appear like this

And Finally, the data appears like this: 

 

Hope that helps!