Pentaho Data Integration: convert number string without separator to decimal - pentaho-data-integration

I'am reading a fixed lenght file with "Text File input" step.
In a position i have a number, let's say: 0000001234
I need to read this number like 1,234, with 3 decimal values.
There is an option to do that? I'have tryed with precision and decimals in the field section of the stp, but they don't work.

Hopefully someone has a more elegant way for this, but you can do it with a calculator step (now improved per marabu's comment).
Make sure your input field is a number type, not an integer.
Add a Calculator step.
Configure a new field "divisor" of type "set field to constant A" and type 1000 under "Field A". Set Remove to Y.
Configure a second field of type "A / B", with A your data field and B the divisor field.

Related

Creating a variable to measure string length

So I'm curious as to what I'm missing here. I have a program for school and part of the program requires that I measure the length of the input string. I have it laid out as "if String==6" which you can see in my code below. My professor would rather it be stored in a variable and that I use the .length method to measure it. His exact words are as follows, "To see if the ticket number is greater than six characters, you need to store it in a variable. Then, on line 19, you can check it by using ticket.length == 6."
I tried using his method and I put "ticket_number.length==6." but that returns an error. Im not sure why, isnt "ticket_number" the variable that needs measured? Or do I need to create another variable just for ticket length? I'm sure there is an easy answer, I just cant seem to find it. Thanks in advance for any and all help!
begin
print "Please enter your six-digit ticket number."
ticket_number=gets.chomp.to_i
ones_digit=ticket_number%10
truncated_number=ticket_number/10.floor
remainder=truncated_number%7
if String=6 and ones_digit==remainder and ticket_number>0
print "Your ticket number is valid."
else
print "Your ticket number is invalid."
end
end while ticket_number>0
There's a couple of problems here but the biggest one is that converting to an integer means you've forfeited your opportunity to test vs. length:
ticket_number = gets.chomp
if (ticket_number.length != 6)
puts "Your ticket number must be six digits"
next
end
You can convert after the fact:
ticket_number = ticket_number.to_i
Then do your math.
Ideally you'd wrap this up in a function that, given a ticket number, will return true or false depending on validity. This de-couples it from your display and looping logic, simplifying things.

Crystal Reports Not Rounding Correctly

I have a formula which is simply 28742.92 / 100.
I have rounding which is set to 0.00001 however it outputs the value 284.
Is it possible to output decimal values as it appears in a standard calculation e.g. 28742.92 / 100 = 284.7289
Many Thanks.
Right click on your numeric field and choose the 4th option from the top Customize field.
Once done, choose the way you want to format your number

SQL Server Reporting Studio (SSRS) sorting error

I am attempting to allow a dynamic sort on a text box on an SSRS report. The field upon which I am trying to sort will either have an "A" or a decimal number. I am wanting to sort the decimal numbers in descending order. The expression I am using is:
=iif(isnumeric(Fields!CommScore.Value), (cdbl(Fields!CommScore.Value)*-1),6)
For the decimal number will never be larger than 5. The error I get is:
The sortexpression for the text box 'textbox74' contains an error. Input string was not in a correct format. (rsRuntimeErrorInExpression)
I imagine this is something simple. What am I doing wrong?
The error relates to the CDbl function throwing an exception when trying to convert A to a number. Yes, I know you're checking if it is numeric first but IIF is not a language construct, it is a function and as a function it evaluates all its parameters before passing them to the function. This means that both the true and false parameters get calculated even though one will be discarded.
Try the Val function. It has the benefit of not erroring when it gets passed non-numeric data - it just does the best it can to convert it.
=IIF(IsNumeric(Fields!CommScore.Value), (Val(Fields!CommScore.Value)*-1), 6)

Tibco - Compare values activity

Let's say I have a value that is passed to a process. What activity should i use to compare this value with another?
I know it may seem a foolish question, but i am new to this.
Assuming you are talking about BusinessWorks, comparing text values of XML attributes or elements is done with XPath using the '=' sign. You don't need to use any specific activity to do so. This can actually be done on any branch (with the "Success with condition" switch) or on the input tab of any activity.
For instance, if you want to compare the text values of 2 elements, you can use an XPath formula like this:
$Start/root/myString1 = $Start/root/myString2
This formula returns true if myString1 and myString2 have the same text value, false otherwise.
Then you can, for example, use this formula as a test condition for an "If" or a "Choice" statement on an input tab of any activity.

Dynamics AX Mandatory Enum field cannot be set correctly through UI

Can anyone explain the following behaviour to me?
When a field type in an AX Table is set to an Enum, you can select any of the Enum values as a value for the field.
But if you make the field Mandatory, you can no longer select the first Enum value in the list through the user interface.
Obviously this can be worked around by not making the field Mandatory. I am looking for an explanation of this bizarre behaviour.
AX does not have a null value concept. Instead the following values are considered "not entered" by defintion:
string: blank
int and int64: 0 (zero)
enum: 0 (typically the first value)
date: 01\01\1900 (displays as blank)
For new base enums make a blank zero enum value (by convention name it None). This will make the use of mandatory fields possible for this enum type.
Also have a look on this: Mark mandatory fields on form, if not filled with valid value
You're saying "if you make the field Mandatory, you can no longer select the first Enum value in the list through the user interface" - this is exactly what the Mandatory property does for enums: prevents you from using a zero value. E.g. if you make NoYesId mandatory you'll be able to enter only Yes because No would no longer be allowed - why would you need it on the form then?
Please also note that from a user perspective it isn't necessarily clear what enum value is zero, so if it didn't work the way it works, understanding what value is not allowed when the enum is mandatory could be tricky.

Resources