Percentage Calculation only from fields with entries? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Percentage Calculation only from fields with entries?

Last post 09-26-2011 02:43 AM by adam1v. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 09-21-2011 10:27 AM

    • adam1v
    • Not Ranked
    • Joined on 09-21-2011
    • Posts 9

    Percentage Calculation only from fields with entries?

    Hi guys, im a real infopath newbie, on a steep learning curve, but enjoying it so far.

     I have 10 fields, lets say field1, field2..... field10, each containing a drop down value of 1-10, with an optional blank choice if the particular item is not applicable. (the user might only fill out fields 1 to 5).

    I would like to work out a percentage score from the fields which do have figures in.

    Firstly, is the above possibly? and secondly, how can I create a percentage from the fields?

    please let me know in really simple, easy to follow instructions, as I've only been using infopath for a few days.

    thanks in advance,

  • 09-22-2011 01:16 AM In reply to

    • adam1v
    • Not Ranked
    • Joined on 09-21-2011
    • Posts 9

    Re: Percentage Calculation only from fields with entries?

    Logically thinking, I think it can be achieved by the following info;

    I have 10 fields, with 1-10, so the maximum score can only be 100 (providing all fields are used).

    What I think I need is "(field1 + field2 + field3 ...+field10) div (100 "then some if statments - if field1 = blank -10, if field2 = blank - 10..... if field10 = blank - 10).

    Does that make sense?

    Any help is really appreciated,

  • 09-23-2011 01:50 AM In reply to

    Re: Percentage Calculation only from fields with entries?

    I have implemented the solution on a mini scale, let me know if you need any explantion.

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 09-23-2011 01:57 AM In reply to

    • adam1v
    • Not Ranked
    • Joined on 09-21-2011
    • Posts 9

    Re: Percentage Calculation only from fields with entries?

    Qazi,

    You are a real gentlemen! I will take a look at the code and compare to what I previously had.

    I think I should be able to expand on this.

    Many, Many thanks

    Adam

  • 09-23-2011 08:22 AM In reply to

    • adam1v
    • Not Ranked
    • Joined on 09-21-2011
    • Posts 9

    Re: Percentage Calculation only from fields with entries?

    Qazi,

    Would you mind explaining on what each of the cells are used for? I can follow it, but just not understand it all fully.

     Thanks,

  • 09-23-2011 10:59 AM In reply to

    Re: Percentage Calculation only from fields with entries?

    Qazi's approach is clever, but I think you can accomplish this with a single formula:

    (field1 + field2 + ... + field10) div (10 * count((field1 | field2 | ... | field10)[. > 0]))

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 09-24-2011 10:52 AM In reply to

    • adam1v
    • Not Ranked
    • Joined on 09-21-2011
    • Posts 9

    Re: Percentage Calculation only from fields with entries?

    Wow, thank you guys, for all your help, the problem is solved.

    @Jimmy, Is it possible to add a translation function into this, to convert say.... "aN" to a zero, such that the NaN error would be replaced with a zero if nothing is filled out?

  • 09-24-2011 11:18 AM In reply to

    Re: Percentage Calculation only from fields with entries?

    Yeah, just try wrapping that whole formula in number(translate(formula, 'aN', '0')).  That should work.

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

    • adam1v
    • Not Ranked
    • Joined on 09-21-2011
    • Posts 9

    Re: Percentage Calculation only from fields with entries?

    That worked a treat thanks. I was already using that formula, but not wrapping it around the whole (existing) formula.

    One last thing, Ive chose to submit this to a sharepoint list, using the file name as:

    Fieldname1 - FieldDate

    The first field is a location and the second is a date. But when saving I get the NaN as the file name.

    Is there a way of getting around this?

  • 09-26-2011 02:34 AM In reply to

    Re: Percentage Calculation only from fields with entries?

    Are you using a concat() formula?  concat(Fieldname1, " - ", FieldDate)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 09-26-2011 02:43 AM In reply to

    • adam1v
    • Not Ranked
    • Joined on 09-21-2011
    • Posts 9

    Re: Percentage Calculation only from fields with entries?

    I wasnt using concat, but there was also a spelling error in my fieldname, all sorted now thanks.

    One last (and very last!), the infopath form submits the date as DD/MM/YYYY (I have also checked the formatting), and displays as this, but when saving, the file name gets reverted to YYYY/MM/DD.

    I have the date field mapped to a column in sharepoint which also displays it correct, its only in the file name its getting swapped around. Any idea why?

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