Help to create a formula using the eval function in InfoPath 2010 - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Help to create a formula using the eval function in InfoPath 2010

Last post 08-08-2012 03:54 PM by Hilary Stoupa. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 07-30-2012 07:46 PM

    Help to create a formula using the eval function in InfoPath 2010

    I am creating a Graduation Plan Infopath form. I am having trouble coming up with an expression to calculate the credits earned.

    Students earn credits by course in two semesters. This are the scenarios:

    pass-pass
    Passing the first semester, half of the credits are earned. Passing the second semester the other half of the credits are earned.

    fail-pass
    Failing the first semester, but passing the second semester full credit are earned. 

    pass-fail
    Passing only the first semester, gives half of the credits.

    fail-fail
    Failing both semesters results on 0 credits earned. 

    Examples:

        First Sem     Second Sem
    Course
    Passing Gr Credits     A  Fall Credit        B  Spring Cr  Accumulated
    (Fall Gr) (Spring Gr)
    pass-pass  English I  70%  4  71%  2  71%  2  4
    fail-pass  English I  70%  4  69%  0  71%  4  4
    pass-fail  English I  70%  4  71%  2  69%  0  2
    fail-fail  English I  70%  4  69%  0  69%  0  0

    I created this on a section inside a repeating table. This is how the form looks like:

    G-Plan

    I was thinking on setting a default value on the 'fallCredit' and 'springCredit' fields using the eval function. Unfortunatley, I haven't been able to understand how to use XPath expressions.

    Can you please help?

    EB
  • 08-01-2012 04:49 PM In reply to

    Re: Help to create a formula using the eval function in InfoPath 2010

    Hi - do you mind attaching a sample form under the Options tab that has the data structure you are displaying above? I'd be happy to give this a try, but it would save me some time to have the schema already created....

    Hilary Stoupa

  • 08-04-2012 05:06 AM In reply to

    Re: Help to create a formula using the eval function in InfoPath 2010

    I uploaded the form. Thanks :-)
    EB
  • 08-06-2012 07:59 AM In reply to

    Re: Help to create a formula using the eval function in InfoPath 2010

    I disabled your rules on field A and field B. I used the following formula as a default for "earned" - since I am not terribly math-y, it most likely has more parenthesis than it needs. :)

    (((A >= passing) * courseCredits) / 2) + (((B >= passing) * courseCredits) / 2)

    Basically, the first boolean condition evaluates to one or zero. I multiply that by course credits and divide by 2 to get the course credits for A. Then I add that to the same logic for B.

    I've attached your template. Save it locally, then you can right click and select Design to open in design mode & preview.

    Hilary Stoupa

  • 08-07-2012 06:38 PM In reply to

    Re: Help to create a formula using the eval function in InfoPath 2010

    Thansk for your post, it works like a charm. I see how you created the formula. It will help me learn how to solve more problems. Thanks a bunch!

    It solves my scenario pass-pass. I still wondering how to make it work in a way it can conditionally solve the other scenarios. Is there an 'if' function?

    EB
  • 08-08-2012 08:57 AM In reply to

    Re: Help to create a formula using the eval function in InfoPath 2010

    In the sample form, if I fill it out with your sample data from your original post, it appears to exactly meet your requirements. Can you tell me how the formula is not working for your other scenarios?


    Hilary Stoupa

  • 08-08-2012 08:58 AM In reply to

    Re: Help to create a formula using the eval function in InfoPath 2010

    Ah, I see - I misunderstood the scenario where they fail first semester but pass the second. I'll see what I can come up with.

    Hilary Stoupa

  • 08-08-2012 03:53 PM In reply to

    Re: Help to create a formula using the eval function in InfoPath 2010

    Okay, I modified the default formula to handle for the fail -> pass scenario.

    (((A >= passing) * courseCredits) / 2) + (((B >= passing) * courseCredits) / (2 - ((A < passing) and (B >= passing))))

    See attached template, I'll post a screenshot with the data as well.

    Hilary Stoupa

  • 08-08-2012 03:54 PM In reply to

    Re: Help to create a formula using the eval function in InfoPath 2010

    Here's a screenshot showing the form with data entered to match your original data....


    Hilary Stoupa

Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.