How do count the content within a field / array ?

  • 28 March 2019
  • 3 replies
  • 15 views

Badge +11

Hello

 

I am using a repated section with a dropdown field [ItemStatus] "Booked" or "Collected".

I also added calculated [total_ItemStatus] value within the form to show the selected options e.g.:

 

[Collected, Booked, Collected]

 

Is there a way to count how many "Collected" are within the [total_ItemStatus] field?
I have tried something like, see below, but not working.

 

count(contains(ItemStatus, "Collected"))

Any advise?


3 replies

Userlevel 5
Badge +14

if ItemStatus field is a choice and/or there is reasonable amount of statuses you could approach it with auxiliary caluclated values - one for each status - that would evaluate to 0/1 based on whether actual status is one the calculation is for or not. finally sum up auxiliary calculations into totals

see similar examples

https://community.nintex.com/t5/Nintex-for-SharePoint/How-to-conditionally-sum-up-the-values-from-a-repeating-section/m-p/20156/highlight/true#M16702

https://community.nintex.com/t5/Nintex-for-SharePoint/Display-value-based-on-day-of-week/m-p/30779/highlight/true#M25357

 

 

 

if ItemStatus is lookup or there are too many statuses, resp. you want to calculate it automatically based on statuses selected, you'd need quite complex javascript solution.

eg. one like @MegaJerk described here

https://community.nintex.com/t5/Nintex-for-SharePoint/Sum-a-a-section-amount-based-on-the-lookup-control/m-p/70284/highlight/true#M58100

Badge +11

Hi

Just to demonstrate my request:

1264i4F938822E2DF9B79.jpg

 

I have taken your suggestion into account and added another Calculated Value within the RepeatedSection naming it [CountItemStatus] as following:

 

if(ItemStatus=="Collected", 1, 0) 

So then I can use sum() to show the total of the amount :) great idea.

sum(CountItemStatus)


My inidial idea was to use the already existing Cal.Value [total_ItemStatus] which then shows the result in a row [Value, Value, Value] (see picture).

 

I thought, maybe, there is away counting from that field how many "Collected" or "Booked" are?

 

By adding more and more Cal.values, it will then generate more entries within the HTML /XML output as it stores into a multiline text field, which I am planning to use later to show user:

 

- how many items you have pending for collection (booked)

- how many items have been collected and by whom.

 

:)

 

Hint: the Items 1 of 1, 2 of 1 etc is yet another calc.value which sums up the [currentRowNumber] and the [Items] which is manually selected by the user as a drop down, to specify the amount of items. In this sample, I left 1 by default hence why it shows 1 of 1 and 2 of 1 . lol

Userlevel 5
Badge +14
I thought, maybe, there is away counting from that field how many "Collected" or "Booked" are?

unfortunatelly, nintex doesn't provide such a functionality.

 

 

 

By adding more and more Cal.values, it will then generate more entries within the HTML /XML output as it stores into a multiline text field, which I am planning to use later to show user:

I'd say that shouldn't matter.

you will anyway need to (pre)process repeater XML into something more undestandable by end users. so you can pick just columns that make sense for them.

Reply