stevebull Posted May 3, 2011 Posted May 3, 2011 Hi again First of all the calculation result is TEXT. I have tried the Round command but cannot get this to work. Would any one have any ideas on this? At the moment, I have something like 12 decimal places and need to report this on the layout as only 3 or 4 significant figures. It is turning into a bit of a pain!!! Thanks all Let ( val = Cosmet2010::Margin of Safety [zz__kf__Cosmet2009RepNum]; Case (not IsEmpty (val); zz__Tab__g & "Margin of Safety Adult 60kg: " & zz__Tab__g & val) )
Fitch Posted May 3, 2011 Posted May 3, 2011 Try putting the calc in the Data Viewer, but set it up like this: Let ( [ rep = zz__kf__Cosmet2009RepNum ; val = Cosmet2010::Margin of Safety [rep]; roundval = Round( val ; 3 ) ; tab = zz__Tab__g ; text = "Margin of Safety Adult 60kg: " result = Case (not IsEmpty (val); tab & text & tab & roundval ) ] ; result ) Then you can try swapping out "result" with the other variables to determine where the problem is ("cannot get this to work" is a little vague).
David Jondreau Posted May 3, 2011 Posted May 3, 2011 Depends...when you say significant digits, do you mean you want "3" to show up as "3.000"? I think you may need something a little more complicated. Try this... Let([ start = Cosmet2010::Margin of Safety [zz__kf__Cosmet2009RepNum] ; integer = int ( start ) ; decimal = start - integer ; decimal1 = Substitute ( decimal ; "." ; "") ; decimal2 = Left ( decimal1 & "000" ; 3 ) ; result = integer & "." & decimal2 ]; result )
comment Posted May 3, 2011 Posted May 3, 2011 The question is indeed not clear. The term "significant figures" has a very precise meaning and I am not at all sure that's what you need. If you only want to format a number to a fixed number of decimal digits, try: Let ( r = Round ( number ; 3 ) ; Int ( r ) & SerialIncrement ( ".000" ; Mod ( r ; 1 ) * 10^3 ) ) Note that this assumes non-negative numbers. --- D J, try 0.0009.
Fitch Posted May 3, 2011 Posted May 3, 2011 I like it. Here's a less mathemagical method: Let ( r = Round( number ; 3 ) + .0001 ; Int( r ) & Left( Right( r ; 5 ) ; 4 ) ) Also assumes non-negative numbers, but could be modified pretty easily to deal with that.
comment Posted May 4, 2011 Posted May 4, 2011 mathemagical LOL. If you prefer to do it with text functions, how about = Let ( [ r = Round( number ; 3 ) ; t = SerialIncrement ( "0000" ; r * 1000 ) ] ; Replace ( t ; Length ( t ) - 2 ; 0 ; "." ) ) This, BTW, will work with negative numbers, too.
stevebull Posted May 4, 2011 Author Posted May 4, 2011 Thanks all I am still working through each idea . The issue with the first one which I should have made clear was that this has a label command. I have attached a screenshot. Basically I would like the phrase 'Margin of safety:' to prefix each number and you can see form teh screen shot that when I add in the new text for 'margin of safety', the labelling prefix disappears. I have yet to try for 'margin of safety baby' etc Thanks Filemaker.bmp
stevebull Posted May 4, 2011 Author Posted May 4, 2011 So how do I incorporate all of that below into my 'margin of safety' text. I am not a filemaker pro like you lot! Let ( [ r = Round( number ; 3 ) ; t = SerialIncrement ( "0000" ; r * 1000 ) ] ; Replace ( t ; Length ( t ) - 2 ; 0 ; "." ) )
stevebull Posted May 4, 2011 Author Posted May 4, 2011 Genius. That worked!!! Phew Let([ start = Cosmet2010::Margin of Safety [zz__kf__Cosmet2009RepNum] ; integer = Int ( start ) ; decimal = start - integer ; decimal1 = Substitute ( decimal ; "." ; "") ; decimal2 = Left ( decimal1 & "000" ; 3 ) ; result = "Margin of Safety Adult 60kg: " & integer & "." & decimal2 ]; result
comment Posted May 4, 2011 Posted May 4, 2011 And how about something simple? TextMerge.zip --- BTW, in case you missed my earlier remark: if you do not round the number first, your result will be inaccurate in 50% of the cases on average.
stevebull Posted May 6, 2011 Author Posted May 6, 2011 Thanks I like that one and stored that for future use. no doubt I can find a use for it
Recommended Posts
This topic is 4954 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now