Hi everyone,
I have a scheduled flow that gets generated Monday morning and the flow looks like this:


The loop wherein I am adding rows and also checking if the current week does it have any Holiday for which I have maintained a separate list


So now I had one more requirement which was some individuals report to office daily (no hybrid mode) that is their work mode status will be WFO. So for them I wanted to add 'WFO' for all the date columns only for those individuals. So I had created a variable (array type) wherein I mentioned those individuals emails like:

Now in the same loop (Add members to Excel) after checking for Holiday or not I wanted to perform a check if the current email (from the Teams action does it match with any of the email defined in the variable (WFO members) if it does then append 'WFO' else leave it blank.
So I have a expression in my mind which is like:
contains(variables('WFO_Members'), items('Add_Team_Member_to_Excel')?['email'])
But I am not sure whether it is correct and the second thing I am not sure where do I need to place it and How?.
And the other thing is if the particular column is already marked as Holiday from the previous check (that particular day like Christmas : 25th Dec) in that case it should not add the WFO text for the set of employees defined in the variable.
Update:
So I did try to update my existing flow with the changes that I mentioned above like:
Added a initialize variable action : With 3 strings (emails)

Then in the Add Members to Excel loop (Apply to each):
Previous code:
(In Row action)
//Here I was only checking if the current week if there are any Holidays as per the Holiday List then append Holiday for that column else leave it blank
if(contains(join(body('Select'),', '),split(outputs('Header'),',')[3]),'Holiday','')
//Now in the else block I modified it slightly:
if(contains(join(body('Select'),', '),split(outputs('Header'),',')[3]),'Holiday',if(contains(variables('WFO_Members'),items('Add_Team_Member_to_Excel')?['email']),'WFO'),'')
Working:
In the outer if (first if):
Check: If the current weekday is there any Holiday:
if(contains(join(body('Select'),', '),split(outputs('Header'),',')[3]),'Holiday',
Then in its else part:
(Check if the current record/item email are they part of WFO_Members array:
if(contains(variables('WFO_Members'),items('Add_Team_Member_to_Excel')?['email']),'WFO'),
And if its not satisfied:
Then leave it blank:
''
The whole expression looks like:
{
"SNo": "@{variables('varCounter')}",
"Employee Name": "@{items('Add_Team_Member_to_Excel')?['displayName']}",
"Employee Email": @{items('Add_Team_Member_to_Excel')?['email']},
"@{split(outputs('Header'),',')[3]}": "@{if(contains(join(body('Select'),', '),split(outputs('Header'),',')[3]),'Holiday',if(contains(variables('WFOMembers'),items('Add_Team_Member_to_Excel')?['email']),'WFO'),'')}",
"@{split(outputs('Header'),',')[4]}": "@{if(contains(join(body('Select'),', '),split(outputs('Header'),',')[4]),'Holiday',if(contains(variables('WFOMembers'),items('Add_Team_Member_to_Excel')?['email']),'WFO'),'')}",
"@{split(outputs('Header'),',')[5]}": "@{if(contains(join(body('Select'),', '),split(outputs('Header'),',')[5]),'Holiday',if(contains(variables('WFOMembers'),items('Add_Team_Member_to_Excel')?['email']),'WFO'),'')}",
"@{split(outputs('Header'),',')[6]}": "@{if(contains(join(body('Select'),', '),split(outputs('Header'),',')[6]),'Holiday',if(contains(variables('WFOMembers'),items('Add_Team_Member_to_Excel')?['email']),'WFO'),'')}",
"@{split(outputs('Header'),',')[7]}": "@{if(contains(join(body('Select'),', '),split(outputs('Header'),',')[7]),'Holiday',if(contains(variables('WFOMembers'),items('Add_Team_Member_to_Excel')?['email']),'WFO'),'')}"
}
So I saved my flow and tested (manually), got this issue (in the loop)

Is there anything that I missed?
So if you guys can help me, it will quite helpful.
If you need any more information do let me know.
Note:
Starting from tomorrow (16/07/2024 to 22/07/2024) probably we might not able to comment on the post as there is some transition that will be happening (from Microsoft) so in that case if comment is disabled, you can message me where we can continue the discussion.
Regards,
Sidhant.