Skip to main content
1-Visitor
July 15, 2016
Question

In a computed field, how do I count the number of items where a pick list is unspecified?

  • July 15, 2016
  • 2 replies
  • 4060 views

I have a picklist that is not required on an item and I want to create a computed field to count the number of items where the picklist has no value yet.  I tried to use the "Unspecified" value, but the following error is returned: 

MKS124543: The field Result is a picklist field. It may only be compared against a picklist value from that field. Unspecified is not a known picklist value.


Thank you,


Paul Hartwig

    2 replies

    1-Visitor
    July 18, 2016

    Paul,

    Here is my two cents.  What if you set the value to "0" instead of "Unspecified"?  Or create a flag field (logical).  The flag could be set to true using a trigger rule.  If a value other then "Unspecified" is selected the trigger would set the flag field to "true".  Another solution (this one might work best) create a new Integer field with computed definition using SelectionCount(Your_Picklist field).  If the picklist is unspecified it will return a 0, if it has a value it will return 1.  Use the value from that field in your computed field to count the number of items where the picklist has no value.

    Hope that helps.

    Dan

    12-Amethyst
    July 27, 2016

    Hi Paul,

    we were also facing this problem some time ago.

    We did not found a solution how to count items, where a picklist field is unspecified.

    As a workaround we created a computation

    <NumberOfAllItems> - <NumberOfItemsWherePicklistHasAnyValue>

    For example (assuming all Picklist-Values are 0 or above:

    isEmpty(

    aggregateByTree("YourRelationshipField",sum(Type="YourType" ? 1 : 0)) -

    aggregateByTree("YourRelationshipField",sum("YourPicklistField">=0 ? 1 : 0))

    ,0)

    Regards

    Markus

    16-Pearl
    August 2, 2016

    Hi Paul Hartwig‌,

    Did Markus Kiessling‌'s response help at all?

    Regards,
    Kael

    1-Visitor
    August 2, 2016

    Kael,

       The solution I used was provided by PTC support.  I created a 2nd field, "Picklist Status",  as a integer with the computation definition set to "SelectionCount(Picklist) == 0 ? 1: 0".  This would set the integer to 0 if the Picklist had a value and to 1 if it does not.  I then hid the field from all users using never relavent.  I then updated my original computed field, with the computation definition set to "aggregateByTree("Item Level 1","Item Level 2",Item Level 3,"Item Level 4","Item Level 5",sum(("Picklist Status" = 1) ? 1 : 0)),0)"  to count the items where the picklist status equals 1, giving me the number of items that have an unspecified value for the picklist.

    If anyone would like further details, please contact me.

    Paul