Calculate Percentages for total - InfoPath Dev
in

InfoPath Dev

Calculate Percentages for total

Last post 05-19-2010 10:39 PM by JonHart. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 05-17-2010 07:08 AM

    Calculate Percentages for total

     Hi there

     Sorry if this has been listed before but I could not find it anywhere. I have a form with 20 questions on it with "Yes" "No" and "N/A" as radio button answers. I have a total field which will give a % score. However, if a person marks a question as N/A the new total question for the % score changes to "Total questions minus number of N/A's selected". It's allot harder to explain typing as I am figuring out now... But hopefully someone understands and can give me an idea on how to go about this. Many many thanks!

  • 05-17-2010 07:27 AM In reply to

    Re: Calculate Percentages for total

     Might it be that the formula you want is:

    100 * count(RepeatingField[Answer = 'yes']) div (count(RepeatingField) - count(RepeatingField[Answer = 'N/A']))

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-17-2010 07:43 AM In reply to

    Re: Calculate Percentages for total

     Hi

     Defiantly looks right but how would I go about using it? Would I just use it as the default value in the total field? Do i replace "RepeatingField" with the fields that I am using? Please excuse my ignorance but only ever worked with very basic forms. Thanks again!!

  • 05-17-2010 07:56 AM In reply to

    Re: Calculate Percentages for total

     Yes, you would use the formula as the default value for the field where you want to store the value, or you can just use the formula in an expression box if you only want to display the value and not store it in the form's data.

     You can use the Select Field... button and its Filter functionality to set up the formula with the correct paths and field names.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-18-2010 01:07 AM In reply to

    Re: Calculate Percentages for total

     Perfect thanks!

     Just one thing, in your string, you used one "Repeating Field", how would I go about adding multiple fields? I have a field for each question, I.e. Q1.1, Q2.2, Q2.3 etc. What would I use to separate the fields?

     Thanks for your assistance with this! 

  • 05-18-2010 03:48 AM In reply to

    Re: Calculate Percentages for total

    you can try

    100 * (fiel1, fiel2, ....fieldn) / number of fields 

    eg: 100 * (field3 + field4 + field5) / 3

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 05-18-2010 04:15 AM In reply to

    Re: Calculate Percentages for total

     Ok i have used the following expression but not liking it...

    100 * count(q2.1 + q2.2 + q2.3 [Answer = "Yes"]) / (count(q2.1 + q2.2 + q2.3)) - (count(q2.1 + q2.2 + q2.3 [Answer = N/A]))

     Where am I going wrong?

  • 05-18-2010 05:12 AM In reply to

    Re: Calculate Percentages for total

    what exactlyy do you want

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 05-18-2010 05:20 AM In reply to

    Re: Calculate Percentages for total

     I want to get a % total for a series of questions which i have used 3 radio buttons for each question, Yes, No and N/A. I need it to calculate the % on all questions minus the ones marked N/A.

  • 05-18-2010 08:46 AM In reply to

    Re: Calculate Percentages for total

     Please try this:

    100 * count((q2.1 | q2.2 | q2.3)[Answer = "Yes"]) / count((q2.1 | q2.2 | q2.3)[Answer != 'N/A'])

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-18-2010 10:54 PM In reply to

    Re: Calculate Percentages for total

     When I use it it joins the [Answer = Yes] the the fields before it.

    100 * count((tq2.1 | tq2.2 | tq2.3)[Answer = "Yes"]) / count((tq2.1 | tq2.2 | tq2.3)[Answer != "N/A"])

     I get the following error.

    "../my:tq2.1/Answer" does not point to a valid location path of a field or group.

  • 05-19-2010 06:20 AM In reply to

    Re: Calculate Percentages for total

     Ok i am now using the following but getting a returned value of 97.....

    100 * count((tq2.1 | tq2.2 | tq2.3)["Yes"]) / count(tq2.1 | tq2.2 | tq2.3) - (count((tq2.1 | tq2.2 | tq2.3)["N/A"]))

    I have tried 

    100 * count((tq2.1 | tq2.2 | tq2.3)["Yes"]) / (count(tq2.1 | tq2.2 | tq2.3) - count((tq2.1 | tq2.2 | tq2.3)["N/A"]))

    which gives me "Infinite" as the value...

     Both of these formula's dont change when answering the questions...

  • 05-19-2010 08:09 AM In reply to

    Re: Calculate Percentages for total

     Please try this:

     100 * count((tq2.1 | tq2.2 | tq2.3)[. = "Yes"]) / count((tq2.1 | tq2.2 | tq2.3)[. != 'N/A'])

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-19-2010 10:39 PM In reply to

    Re: Calculate Percentages for total

     Hi

     I must have figured out the [. = "yes"] prob about 1 minute before you posted. have finally come right. Thanks SOOO much for your help@!!!!@@#@#!

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