Hi,
I have a field in my data files data point is .0100. I want to be able to convert into 1.00%.
How can I change that in my data mapper?
thank you.
Hi,
I have a field in my data files data point is .0100. I want to be able to convert into 1.00%.
How can I change that in my data mapper?
thank you.
one way to do this is to create a new data field manually (of type string) and in an Action step assign that field the converted value as you need it (by running Javascript), e.g.:
var numberPercent = parseFloat(record.fields.COLUMN2) * 100;
record.fields.col2num = numberPercent.toString() + '%';
where COLUMN2 is the data extraction field which holds the raw value (‘.0100’ in your sample, and which is a string I guess), and col2num is your custom field.
Another way is to put the following in the Post Function of your extract field.
replace(“.0100”,“1.00%”);
However this is assuming that all the data is .0100. If you do have a few others, but not many then you can also do…
replace(“.0100”,“1.00%”).replace(“.100”,“1.00%”);
Regards,
S
A generic way of doing this with the Post Function of the extract field:
replace( /(.*)/ , function(match) {return match*100+"%";} );
This uses a Regular Expression to capture the entire string (.*) and specifies a function that multiplies that string by 100, adds the percent sign and returns this as the new value.