is there any method to roundup the decimal values for example in measures i am defining BaseAmount:{
sql:'BaseAmount',
type:sum
},
I am getting sum of all baseAmount value like this 693.3399999999993 because here I mentioned type as sum I need to round up these values as 693.3 for that what type I need to declare
Asked
Active
Viewed 415 times
0

Artyom Keydunov
- 9
- 1
-
To perform this directly in Cube and not in js, you can do: `BaseAmount:{ sql:'round(sum('BaseAmount'), 1), type:number }` – Étienne Dec 15 '21 at 10:15
1 Answers
0
You can use the Math.round function in js. See the below snippet.
let sum = 693.3399999999993;
let rounded = Math.round( sum * 10 ) / 10;
console.log(rounded)

Learner
- 8,379
- 7
- 44
- 82
-
In Need to format the value in cube js https://cube.dev/docs/measures – harini shree Jan 21 '20 at 05:24