Add Square root to a filed calculation? - InfoPath Dev
in

InfoPath Dev

Add Square root to a filed calculation?

Last post 01-09-2014 09:26 AM by motor1. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 12-13-2011 12:06 PM

    Add Square root to a filed calculation?

    I  have two fields and I want to show the square root instead of a decimel value.  How is this done?  I found some C# and VB code that looks like it might work, but I am not sure where to put the code.  Any help appreciated.
  • 12-13-2011 01:23 PM In reply to

    Re: Add Squire root to a filed calculation?

    I'm not sure what you mean by "the square root instead of a decimel[sic] value."  How is a square root an alternative to a decimal value?

    At any rate, it's a bit convoluted but I'm attaching a form that performs a square root operation without any code at all.  It makes use of a secondary data source, and the rules on the Start and Step fields in that data source.  Best of luck.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-13-2011 01:26 PM In reply to

    Re: Add Squire root to a filed calculation?

    As long as I can get a field to display a square root I'm happy.  I may need to apply it to several fields on the form.  Where do I put these files exactly?
  • 12-13-2011 01:33 PM In reply to

    Re: Add Squire root to a filed calculation?

    so how would I do:

    field1 = Square root of field 2?

  • 12-13-2011 01:39 PM In reply to

    Re: Add Squire root to a filed calculation?

    Please redownload the ZIP as I've reposted a simpler approach.

    You would add the XML file as a secondary data source.  Then set up the rules the same way as they are in my example XSN.  Then to set field1 = Square root of field 2, you would:

    1. Set Start to the value of field2

    2. Set field1 to the value of Result

    That's it!

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-14-2011 05:57 AM In reply to

    Re: Add Squire root to a filed calculation?

    I added that but the field does not populate any data.  Just stays blank but your sample works.  I have added the rules, etc.  I noticed in yours there is resource files Squareroot1, and 2.  I don't have those.  I have the form and xml file in the same path.  What am I missing?

  • 12-15-2011 08:56 PM In reply to

    Re: Add Squire root to a filed calculation?

    Hello sentinelace,

    It appears that you haven't defined any rules in the SquareRoot data source at all.  You need to imitate all of the rules that I have on the Start and Step fields.

    Also, I mentioned that I uploaded a simpler implementation than I had before.  It looks like you still have the old one.  Please download the newer one and use that (it doesn't have stop, Min, or Max fields).


    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-16-2011 06:48 AM In reply to

    Re: Add Squire root to a filed calculation?

    yeah missed that.  Added the rules and now works like a champ!  Thanks for your help.  Why couldn't they just add a square root button to infopath? LOL
  • 01-08-2014 09:42 AM In reply to

    • motor1
    • Not Ranked
    • Joined on 01-08-2014
    • Posts 3

    Re: Add Squire root to a filed calculation?

    anyway to do ^1/5 with this? if possible please let me know thanks much
  • 01-08-2014 04:39 PM In reply to

    Re: Add Squire root to a filed calculation?

     Yes, you can do this by replacing the formula on the Step field with this formula:

    (4 * Result + Start / (Result * Result * Result * Result)) / 5

    This is also very easy to calculate x ^ 1/5 using a single command in qRules:

    concat("Pow /power=0.2 /value=", Field)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-09-2014 09:26 AM In reply to

    • motor1
    • Not Ranked
    • Joined on 01-08-2014
    • Posts 3

    Re: Add Squire root to a filed calculation?

    Thanks for the reply, but when i put in a value of let's say 10 it'll give me the correct result. but if i put in a value of .001 it'll give me result of 935.361047895519 which is wrong, the correct result should be 0.251188643
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.