cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Workflow Hero

Count items within a collection

Jump to solution

Hi community,

I have a problem with counting items within a collection (there are three items in that collection), and I am already getting mad about this. I tried three different approaches:

First try (Regular Expression):

RESULT
colFachabteilungen: ["{\"__metadata\":{\"type\":\"Collection(Edm.String)\"}","\"results\":[\"Fachabteilung 1\"","\"Fachabteilung 2\"","\"Fachabteilung 3\"]}"]

Count items object used:

RESULT
intAnzahlFachabteilungen: 4

Second try (Query List):

RESULT
colFachabteilungen: [["Fachabteilung 1","Fachabteilung 2","Fachabteilung 3"]]

RESULT
intAnzahlFachabteilungen: 1

Third try (List Lookup):

RESULT
colFachabteilungen: {"__metadata":{"type":"Collection(Edm.String)"},"results":["Fachabteilung 1","Fachabteilung 2","Fachabteilung 3"]}

Count items object used:

RESULT
intAnzahlFachabteilungen: 2

So I received "4", "1" and "2" whereas it should be THREE!!!!!

Aaaaaaaaaaaaaahhhhhhh.........

PLEASE tell me what I am doing wrong.

PS: I am using 

Labels: (1)
0 Kudos
Reply
7 Replies
Workflow Hero

Re: Count items within a collection

Jump to solution

can you not use collection operation - count?

0 Kudos
Reply
Workflow Hero

Re: Count items within a collection

Jump to solution
0 Kudos
Reply
Workflow Hero

Re: Count items within a collection

Jump to solution

I used the "Count Items in Collection" object in my first and third try:

I don't know why it does not work.

0 Kudos
Reply
Workflow Hero

Re: Count items within a collection

Jump to solution

If you query the list and be sure to Store Output in separate collection then the COUNT collection will work.

0 Kudos
Reply
Workflow Hero

Re: Count items within a collection

Jump to solution

Hi Ryan,

Isn't that what I have done in my "second try"? Ok, I didn't use an extra/separate Count Object here, because the Query List object has a result count for itself. Nevertheless I added the Count Object and received the same number as with the included result count within the Query List object: 1 (see also initial posting "second try").

Cheers

mai-kel

0 Kudos
Reply
Workflow Hero

Re: Count items within a collection

Jump to solution

Sorry, didn't see that you had used that setting.

Your output doesn't look correct.

[["Fachabteilung 1","Fachabteilung 2","Fachabteilung 3"]]

This is an array inside your collection.

Your collection should look like

["Fachabteilung 1","Fachabteilung 2","Fachabteilung 3"]

I think I've figured out the issue whilst typing this in fact. I'm guessing that Fachabteilungen is a multi select choice column or similar.

This would explain why your query list doesn't work as you're only looking to return a single result that contains 3 values. Not 3 results.

There might be a more elegant way of doing but you could add a regex in to remove the leading [ and trailing ]. This will leave your collection in the correct format to perform operations on.

Reply
Workflow Hero

Re: Count items within a collection

Jump to solution

Hi Ryan,

You are right - it is a multi select choice column.

And with the help of my colleague Jan von Reith‌ I found a solution (I guess the same solution you were refering to):

1. Query list object:

         column into COLL variable

2. Regular expression object:

         String: COLL variable

         String operation: Split

         Pattern: ,

         Output: COLL variable

3. Count Items in COLL object

Cheers

mai-kel

Reply