how to the get the Pentaho table values with Decimal - pentaho-spoon

I am using Pentaho-code I am round the queries values as decimal but getting some colums values not decimal
table output:
NORMAL (06:00--17:00) 3 14341.54 43024.62
OFF_PEAK (22:00--06:00) 3 7002.39 21007.170000000002
PEAK (17:00--22:00) 3 9362.95 28088.850000000002
required output
NORMAL (06:00--17:00) 3 14341.54 43024.62
OFF_PEAK (22:00--06:00) 3 7002.39 21007.17
PEAK (17:00--22:00) 3 9362.95 28088.85

Column formats %.2f will definitely work to show 2 decimal point. You just need to be define column formats for every column. For string you need to define %s, for only real digit use %d, and to get 2 decimal you need to define %.2f etc.
You can have a look in my sample image for correct configuration-

Related

PostgreSQL rounding error | Sum of differences between values and difference between sum of values are not equal

I am trying to evaluate numbers upto 3 decimal precision. The formulas are fairly simple but sum of differences between values and difference between sum of values are not equal.
The dataset contains nearly 2050 entries.
result_column_1 = SUM(column1) - SUM(column2)
result_column_2 = SUM(column1-column2)
I am getting a huge dissimilarity between result_column_1 and result_column_2
column1 and column2 are already truncated (not rounded) to 3 decimal places.
1. ROUND() - didn't work
2. CAST TO Demical, Numeric - didn't work
3. TRUNC() - didn't work

How to convert integer number so that they have n decimal places in PostgreSQL SELECT

How can numbers converted so that they have n decimal places?
I want to convert all numbers of a column so that they have three decimal places.
For example the query result should look like this
Amount
3.000
2.511
3.200
...
Please see this page: https://www.postgresql.org/docs/current/functions-formatting.html
select to_char(amount, '999D999') as "Amount"
from your_table;

How to fix the decimal place of matrix elements in matlab?

I have a matrix of order 3 x 3, and all elements of matrix are up to 6 decimal place. I want to display this elements of matrix only up to 5 decimal place. I used format short and format long, but it gives either 4 or 15 decimal places.
Is there a command that gives up to any particular decimal places?
I have idea for a single number but could not solve for all entries of a matrix.
The builtin format options cannot handle this. You'll instead want to use fprintf or num2str (with a format specifier) to force the appearance of the number
data = rand(3) * 100;
num2str(data,'%12.5f')
% 20.42155 3.95486 91.50871
% 9.28906 87.24924 72.61826
% 47.43655 95.70325 94.41092
If you want to make this the default display at the command line you could overload the builtin display method for double but I would not recommend that.
Alternately, you can use vpa to specify the number of significant digits to display (note that the second input is the number of significant digits and not the number of numbers after the radix point).
vpa(data, 5)

How can I set a format for each column when displaying my table?

My table only contains numerical data. I have format set to long and all of the variables are of that type. How can tell MATLAB to display each column differently? i.e column 1 as type long with 15 decimal digit precision, column 2 in scientific notation with 4 decimal precision, etc?

Crystal Reports Formula: Getting the decimal and non-decimal part

For example I have a value of 103.33 I want to put 100 to one variable and 33 to another variable. How can I do this?
Thanks.
Create two formula fields, eg wholepart and decimalpart.
The formula for wholepart is trunc({yourfieldnamehere}) and the formula for decimalpart is {yourfieldnamehere} - trunc({yourfieldnamehere})
The value you get in decimalpart is going to be the decimal fraction; if you know it's always going to be a 2 digit decimal, multiply by 100. If it's variable, you could do a quick string conversion, count the digits and multiply by the appropriate power of 10.
Hampk
Use trunc to get Integer portion and then subtract to get decimal portion. Convert decimal portion to text by ToText and then take Split function to get after "." from decimal portion
or
Use ToText and use Split function to get after and before "."
You can also use the 'Remainder' function to find the number after the decimal point. For example, REMAINDER ({FIELD NAME},1) should give you 0.33