
Here’s how you can set up a Power Automate flow to update a column based on multiple conditions from a SharePoint choice column:
First, it would be easier to manage the mapping of Tasks to Team Groups if you create a separate SharePoint list (e.g., Task-TeamGroupMapping) to store the task-to-team group relationships.
Task-TeamGroupMapping List Structure:
TaskName (Choice or Single Line of Text)
TeamGroup (Single Line of Text)
Populate this list with all 126 tasks and their corresponding 25 team groups.
Manually Trigger the Flow:
Create a new flow in Power Automate.
Select "Manually trigger a flow" as the trigger.
Get Items from the SharePoint List:
Add an action: "Get items".
Configure it to point to your main SharePoint list where tasks are selected by users.
Get Task-Team Group Mappings:
Add another action: "Get items".
Configure it to point to your Task-TeamGroupMapping list.
Loop Through Each Item:
Add an "Apply to each" action.
Select the value from the main SharePoint list as the output for the "Apply to each" action.
Find Corresponding Team Group:
Inside the "Apply to each" action, add a "Filter array" action.
Use the output from the Task-TeamGroupMapping list.
Set the condition to match the TaskName from the main SharePoint list to the TaskName from the Task-TeamGroupMapping list.
@equals(items('Apply_to_each')['TaskName'], item()['TaskName'])
Update the Item in the Main List:
Add a "Condition" action to check if the filtered array is not empty.
If the condition is true (array is not empty):
Add an "Update item" action.
Set the item ID to the ID of the current item in the main list.
Set the TeamGroup field to the value from the filtered array.
Initialize an array variable to store Task-TeamGroup mappings.
Type: Array
Name: TaskTeamGroupArray
Value: []
Get items from the Task-TeamGroupMapping list and append them to TaskTeamGroupArray.
In the "Apply to each" action, use a "Filter array" to find the corresponding TeamGroup.
Use a "Compose" action to extract the TeamGroup from the filtered array.
Use the "Update item" action to update the TeamGroup field in the main list.
Error Handling: Add error handling to ensure the flow can gracefully handle any issues, such as missing tasks or team groups.
Optimization: To improve performance, consider batching updates if you have a large number of items.