akappycanfieldtack.com Posted April 19, 2010 Share Posted April 19, 2010 How do I maintain two decimals if result is ***.00 or ***.x0? Adding ***.00 + ***.00 getting yyy (no decimal, no zeros). Tried adding a ".00" at the end, but if there was a ***.50, my trailing ".00" cancatenated and became, yyy.5.00 Link to comment Share on other sites More sharing options...
esmith Posted April 19, 2010 Share Posted April 19, 2010 Are you using the FormatNumber() function? return FormatNumber("0.00", YourData); Link to comment Share on other sites More sharing options...
akappycanfieldtack.com Posted April 19, 2010 Author Share Posted April 19, 2010 Eric, I was mis-using "FormatNumber" and your suggestion made me take a fresh look. Works great now. Thanks, Andy Link to comment Share on other sites More sharing options...
n2_space Posted October 13, 2011 Share Posted October 13, 2011 I'm confused... and new to JS var ZIP CODE = ZIP (); return FormatNumber("0", ZIP ); I want it to return no decimal or decimal places... any help greatly appreciated! Link to comment Share on other sites More sharing options...
esmith Posted October 13, 2011 Share Posted October 13, 2011 What does you data for zip code look like and what is the name of the field it is provided in? Link to comment Share on other sites More sharing options...
n2_space Posted October 14, 2011 Share Posted October 14, 2011 What does you data for zip code look like and what is the name of the field it is provided in? when I preview is looks like: 12345.0 and the field is ZIP CODE thanks! Link to comment Share on other sites More sharing options...
Dan Korn Posted October 14, 2011 Share Posted October 14, 2011 when I preview is looks like: 12345.0 and the field is ZIP CODE Assuming the ZIP CODE field contains just the five-digit Zip code in the data, you should just be able to use that field directly in your text frame. I don't think you need to use a JavaScript rule at all. Link to comment Share on other sites More sharing options...
n2_space Posted October 14, 2011 Share Posted October 14, 2011 Assuming the ZIP CODE field contains just the five-digit Zip code in the data, you should just be able to use that field directly in your text frame. I don't think you need to use a JavaScript rule at all. In the excel file it is just five digits, but for some reason when I make it a variable field in FP, it comes up with a decimal and 0 (hence 12345.0 instead of 12345). I was wanting to write a rule to get around it and make it display correctly. any thoughts? Link to comment Share on other sites More sharing options...
Dan Korn Posted October 14, 2011 Share Posted October 14, 2011 In the excel file it is just five digits, but for some reason when I make it a variable field in FP, it comes up with a decimal and 0 (hence 12345.0 instead of 12345). I was wanting to write a rule to get around it and make it display correctly. How are you bringing the data in from Excel to FusionPro? Are you exporting to a flat file, like a CSV file? If so, that's the input to FusionPro, not the Excel file itself. So, what does the data look like in the flat file? You might need to fix something in Excel so that the CSV file has the data in the correct format. But still, you should be able to do this: return FormatNumber("00000", Field("ZIP CODE")); Link to comment Share on other sites More sharing options...
n2_space Posted October 14, 2011 Share Posted October 14, 2011 How are you bringing the data in from Excel to FusionPro? Are you exporting to a flat file, like a CSV file? If so, that's the input to FusionPro, not the Excel file itself. So, what does the data look like in the flat file? You might need to fix something in Excel so that the CSV file has the data in the correct format. But still, you should be able to do this: return FormatNumber("00000", Field("ZIP CODE")); as odbc... the problem with this is that we use the same template many times and don't want to have to redo the databases that come all the time thanks for the help, I will give it a whirl Link to comment Share on other sites More sharing options...
n2_space Posted October 14, 2011 Share Posted October 14, 2011 works great, thanks Dan! Link to comment Share on other sites More sharing options...
WRPrint Posted May 30, 2012 Share Posted May 30, 2012 How are you bringing the data in from Excel to FusionPro? Are you exporting to a flat file, like a CSV file? If so, that's the input to FusionPro, not the Excel file itself. So, what does the data look like in the flat file? You might need to fix something in Excel so that the CSV file has the data in the correct format. But still, you should be able to do this: return FormatNumber("00000", Field("ZIP CODE")); I am bringing in a .CSV file that does not keep the trailing zeros, now trying to create an accounting style look to numbers, I need the trailing zeros. I understand the use for the FormatNumber, but is there a way to make a global rule for multiple fields instead of having to create so many rules and variables? Would I really need to go through and create a FormatNumber on each Field? I have something like 152 overall numerical fields that vary in trailing numbers, and like I said, if there is a global functionality to this without having to create a RULE for each Field that would be most excellent. Thanks. Link to comment Share on other sites More sharing options...
Dan Korn Posted June 1, 2012 Share Posted June 1, 2012 I am bringing in a .CSV file that does not keep the trailing zeros, now trying to create an accounting style look to numbers, I need the trailing zeros. I understand the use for the FormatNumber, but is there a way to make a global rule for multiple fields instead of having to create so many rules and variables? Would I really need to go through and create a FormatNumber on each Field? I have something like 152 overall numerical fields that vary in trailing numbers, and like I said, if there is a global functionality to this without having to create a RULE for each Field that would be most excellent. Thanks. You can do something like this in OnRecordStart: for (var v in FusionPro.Fields) FusionPro.Composition.AddVariable(v, FormatNumber("00000", FusionPro.Fields[v])); This will "inject" new variables for the composition, overriding the original field values. However, this will affect every field in the job, rendering non-numeric fields empty, so you probably want to filter it somehow. Ideally this would be done by field name. I don't know the field names in your job, but it would be something like this: for (var v in FusionPro.Fields) { if (ToUpper(v).indexOf("ZIP") >= 0) FusionPro.Composition.AddVariable(v, FormatNumber("00000", FusionPro.Fields[v])); }Or you could do something like this to apply the formatting only to fields which contain nothing but digits: for (var v in FusionPro.Fields) { if (FusionPro.Fields[v] && FusionPro.Fields[v].search(/\D/) < 0) FusionPro.Composition.AddVariable(v, FormatNumber("00000", FusionPro.Fields[v])); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.