It's just a very big or() function which will return true if any of the functions within return true. 🙂
or(not(equals(item()?['Hong Kong'], '')), not(equals(item()?['Shanghai & Shenzen'], '')), not(equals(item()?['Northbound Trading'], '')), not(equals(item()?['Southbound Trading'], '')), not(equals(item()?['United States'], '')), not(equals(item()?['Japan'], '')), not(equals(item()?['Korea'], '')))
Then the Boolean variable afterwards contains this expression:
if(
greater(
length(
union(
body('Select_any_holidays'),
body('Select_any_holidays')
)
),
1
),
true,
equals(
union(
body('Select_any_holidays'),
body('Select_any_holidays')
)[0]?['Any Holidays'],
true
)
)
- union() - compares the two arrays to each other, and removes duplicates.
- length() - counts the amount of items inside it.
- greater() - checks if a number is greater than another number.
- if() - if the function listed first is true this returns the value of the second part, if it is false, then the last.
So first it compares the Select any holidays array to itself, then removes any the duplicates for a new array. If there were only false results you will have only one item in this array, if there were any true results, there will be two items in the union(). So any number greater than 1 equals true.
So setting the true value is simple, in the second part here.
Lastly, you have to check in the remote possibility that they are all holidays, in which case you will only get one result, but it will be true. So if the number is not greater than 1, then this function will run an equals() check on the first item that the union() creates. If that is true, then there are holidays EVERYWHERE! 😅
It's just a very big or() function which will return true if any of the functions within return true.
or(not(equals(item()?['Hong Kong'], '')), not(equals(item()?['Shanghai & Shenzen'], '')), not(equals(item()?['Northbound Trading'], '')), not(equals(item()?['Southbound Trading'], '')), not(equals(item()?['United States'], '')), not(equals(item()?['Japan'], '')), not(equals(item()?['Korea'], '')))
Then the Boolean variable afterwards contains this expression:
if(
greater(
length(
union(
body('Select_any_holidays'),
body('Select_any_holidays')
)
),
1
),
true,
equals(
union(
body('Select_any_holidays'),
body('Select_any_holidays')
)[0]?['Any Holidays'],
true
)
)
union() - compares the two arrays to each other, and removes duplicates.
length() - counts the amount of items inside it.
greater() - checks if a number is greater than another number.
if() - if the function listed first is true this returns the value of the second part, if it is false, then the last.
So first it compares the Select any holidays array to itself, then removes any the duplicates for a new array. If there were only false results you will have only one item in this array, if there were any true results, there will be two items in the union(). So any number greater than 1 equals true.
So setting the true value is simple, in the second part here.
Lastly, you have to check in the remote possibility that they are all holidays, in which case you will only get one result, but it will be true. So if the number is not greater than 1, then this function will run an equals() check on the first item that the union() creates. If that is true, then there are holidays EVERYWHERE!