Hi, @KONeill102399 , couple of things that I think that you might need:
- Make A 'uniqueActionsArrVAR' Array Variable - I am pretty sure that you'll need to build an array of values from that 'Actions' column, then run an apply to each on a union() of that array
- Remove 'Format Table Headers' Action - I'm making an assumption here, but the 'Select Data from Query' action is going to enable you to set your headers, then you can use the 'Create HTML Table' on auto afterwards. (or just go straight to the table!)
The need for the first is because you cannot be sure that all the actions will be the same, so your Switch action would not be run appropriately, as it would not have direct data to feed off of. Once you are inside that unique array, though, you can just place 'Current item' in the Switch 'On' field.
I think this is why @creativeopinion was wondering why there wasn't any flow actions around handling those Actions from from BI data.
How To Iterate Over The Actions
All of this is hopefully not too strenuous to achieve ... I have edited in here some steps to ensure that you are not making 3 email actions:
- Initialize two new variables before all your other actions:
- Array - Named 'uniqueActionsArrVAR'
- String - Named 'emailRecipientsVAR'
- After the Power BI action make a separate Select action (don't delete your current one) and rename it 'Select uniqueActions'
- In the 'From' field use the same value as you did in the other
- In the 'Map' field you might need to get a bit creative, but hopefully you can just select the column
That will result in a string array, that should look something like the example below these steps
- After the Select action create a Set variable action to set the 'uniqueActionsArrVAR' value then within that:
- ... in the 'Value' field of this action open the expression builder instead of using dynamic data
- ... add the union() function
- ... inside the union function add the output of 'Select uniqueActions' twice, comma separated
Each time this runs you will now have a definable list of whether any actions are needed
- Now add an Apply to each action after all the other important actions in the flow (the ones you've shown us):
- In the 'Select an output from previous steps' field of the Apply to each select 'uniqueActionsArrVAR' from the Dynamic data
- As the first step create a Switch action and in the 'On' field select 'Current item' from the Dynamic data and make your 3 cases:
- supervisor
- manager
- no action
- After the switch add your email action and in the 'To' field pick the 'emailRecipientsVAR' from the Dynamic data and fill out the email with all the data
Select Output Examples
The output from the Select Action in #3 might look like this:
[
"supervisor",
"manager",
"no action"
]
Or it might look like this:
[
"supervisor",
"no action"
]
It will all depend on what actions are listed in the BI data.
Moving Forward
Now you have your Switch and it will run on whichever values you choose in the cases, with whichever actions that you wish to have taken within them for each!
Additionally, if you wanted to be super clever, much of this could be done in parrallel to your other actions, then run your Apply to each action after everything. This would assist with making the flow more efficient. 🙂
If you wished to personalise the body of the email for supervisor/manager/no action, then either move the email action back into the Switch, or make an email body variable to edit there.
When making new actions it's good to get into the habit of giving them unique names, too. To make it easy for myself on things like initializing variables I simply copy the variable name and paste it in instead of the word 'variable' in the renaming.