Express Yourself: Collection Functions in Microsoft Flow

In this post, I will discuss all the Collection functions that can be used in Microsoft Flow. These functions generally work with Arrays, Strings, and Dictionaries.

Function
Description
contains
This function checks if a collection has a specified item. This function requires two parameters: the collection to check and the value of the item to find. If the item is found in the collection, the function returns true, but if not, it returns false.
Function: contains(collection, value)
Example: contains(‘Hello Microsoft Flow, ‘Microsoft’)
Output: true
Additional Examples: Click here
length
This function returns the number of items in a string or an array. This function only requires one parameter, which is the collection with the items to count. The function returns an integer indicating the number of items in the given collection.
Function: length(collection)
Example: length(‘Microsoft Flow’)
Output: 14
Additional Examples: Click here
empty
This function checks if a collection is empty. This function only requires one parameter, which is the collection to check. If the collection is empty, the function returns true, but if not, it returns false.
Function: empty(collection)
Example: empty(”)
Output: true
Additional Examples: Click here
intersection
This function returns a single array or object that has common elements between the arrays or objects passed in. For parameters, this function only requires the collections to evaluate. The parameters for this function can either be a set of objects or a set of arrays, not a mixture of both. To appear in the result, an item must appear in all the collections passed to this function.
Function: intersection(collection_1, collection_2,…)
Example: intersection([0,1,2,3], [1,2,3,5,6,7])
Output: [1,2,3]
Additional Examples: Click here
union
This function returns a single array or object with all the elements that are in the array or object passed in. For parameters, this function only requires either the array or object from where we want all the items. The parameters for this function can either be a set of objects or a set of arrays, not a mixture of both. If there are two objects with the same name, the last item with that name appears in the result.
Function: union(collection_1, collection_2?,…)
Example: union([0,1,2,3,4], [1,4,5,9,12])
Output: [0,1,2,3,4,5,9,12]
Additional Examples: Click here
first
This function returns the first item from an array or a string. For parameters, this function only requires the collection to take the first item from.
Function: first(collection)
Example: first(‘Microsoft Flow’)
Output: “M”
Additional Examples: Click here
last
This function returns the last item from an array or a string. For parameters, this function only requires the collection to take the last item from.
Function: last(collection)
Example: last(‘Microsoft Flow’)
Output: “w”
Additional Examples: Click here
take
This function returns the first count elements from a given array or string. This function requires 2 parameters: the collection from where to take the first count elements and a positive integer for the number of items we want.
Function: take(value, count)
Example: take(‘Microsoft Flow’, 4)
Output: “Micr”
Additional Examples: Click here
skip
This function returns the elements in the array starting at the given index count. This function requires 2 parameters: the collection to skip the first count objects from and a positive integer for the number of items to skip.
Function: skip(collection, count)
Example: skip([1,2,5,6], 2)
Output: [5,6]
Additional Examples: Click here
join
This function returns a string with each item of an array joined by a delimiter. This function requires 2 parameters: the collection to join items from and the separator that appears between each character in the resulting string.
Function: join(collection, delimiter)
Example: join([0,1,2,3], ‘.’)
Output: “0.1.2.3”
Additional Examples: Click here

Photo by Jon Tyson on Unsplash

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s