metricspower-automatemicrosoft-planner

How to automatically grabbing the tasks from planner into Metrics/goal?


Hi PowerAutomate/Flow experts,

In the planner there are following tasks from projects: Lavender, Marigold & Teal

Abhi_2023_0-1700740158593.png

The Goal is automatically get the tasks from planner into Metrics as below Abhi_2023_1-1700740195738.png

In Flow:

Since there is no way to group the tasks for relevant projects, it is hard to map them on to Metrics using PowerAutomate:

Abhi_2023_2-1700740231763.png

We can group by Buckets or 1-1 tasks from Planner to Metrics but looking for ways to group tasks via either labels or something else !

UPDATE: When used "gettask" to grab appliedCategories, there is no specific category shown in raw output. Also, how can we group such categories ? should we use a loop & condition ?

raw output

Added task with appliedcategories = Dark green (category18)

planner with tast named task-planner adding condition to check the task above added with appliedCategories but still not catching it leading to escaping the condition too.

:(

replicating the sam answer...Not sure what Create Label here means and there is no current item from the Filter TaskbyLabel in new view

error when replicated

Thanks @Sam for your efforts to help us. It seems even after adding the expresssion, it lead to error. Get Plan Details- Bad Request

Also, for the final step, is Output should be UniqueLabels ? FilterTaskByLabel step

4 points

Update

error 1

In the step above RenamedLabelNames....there need to be ApplyToEach

GetPlanDetails


Solution

  • Your overall question is pretty broad, however, I will answer your immediate need of "how to group tasks by label". Hopefully that will get you on your way.

    Let me say first, I have yet to receive the new UI for Power Automate, so the following is based on the old UI. Just the same, you should be able to apply the same steps/expressions.

    Here's the overview of the steps:
    enter image description here

    And the details behind each step/action:

    // Name: DefaultLabelNames
    // Action: Data Operation > Compose
    // Note: These are the default names of the categories (labels)
    // Inputs:
    {
      "category1": "Pink",
      "category2": "Red",
      "category3": "Yellow",
      "category4": "Green",
      "category5": "Blue",
      "category6": "Purple",
      "category7": "Bronze",
      "category8": "Lime",
      "category9": "Aqua",
      "category10": "Gray",
      "category11": "Silver",
      "category12": "Brown",
      "category13": "Cranberry",
      "category14": "Orange",
      "category15": "Peach",
      "category16": "Marigold",
      "category17": "Light green",
      "category18": "Dark green",
      "category19": "Teal",
      "category20": "Light blue",
      "category21": "Dark blue",
      "category22": "Lavender",
      "category23": "Plum",
      "category24": "Light gray",
      "category25": "Dark gray"
    }
    
    // Name: List tasks
    // Action: Planner > List tasks
    // Note: Gets all the tasks for a Plan
    // Inputs: Select your Group Id and Planner Id
    
    // Name: Get plan details
    // Action: Planner > Get plan details (Preview)
    // Note: Needed to get any custom renaming of labels (categories)
    // Plan Id:
    first(outputs('List_tasks')?['body/value'])?['planId']
    
    // Name: RenamedLabelNames
    // Action: Data Operation > Compose
    // Note: Any custom naming of the labels
    // Inputs:
    outputs('Get_plan_details')?['body/categoryDescriptions']
    
    // Name: PlanLabelNames
    // Action: Data Operation > Compose
    // Note: Giving the resulting label names of default and custom
    // Inputs:
    union(outputs('DefaultLabelNames'), outputs('RenamedLabelNames'))
    
    // Name: Tasks
    // Action: Data Operation > Select
    // Note: Array of tasks that we'll filter later on. Add each field that you need to later create the PBI Metric.
    // From:
    outputs('List_tasks')?['body/value']
    // Map: main one here is "Label" - set it to:
    outputs('PlanLabelNames')?[ coalesce(split(string(item()?['appliedCategories']), '"')?[1], 'nolabel') ]
    

    enter image description here

    // Name: SelectTaskLabel
    // Action: Data Operation > Select
    // Note: Single field array of all the labels in all the tasks
    // From:
    body('Tasks')
    // Map:
    item()?['Label']
    

    enter image description here

    // Name: UniqueLabels
    // Action: Data Operation > Compose
    // Note: Unique/distinct list of labels
    // Inputs:
    union(body('SelectTaskLabel'), body('SelectTaskLabel'))
    
    // Name: ForEachLabel
    // Action: Control > Apply to each
    // Note: Loop through each distinct label
    // Inputs:
    outputs('UniqueLabels')
    

    enter image description here

    // Name: FilterTaskByLabel
    // Action: Data Operation > Filter array
    // Note: Filter previous Tasks array by label
    // From:
    body('Tasks')
    // Condition:
    item()?['Label'] /* is equal to */ items('ForEachLabel')