“Power Automate allows me to get the progress from a Planner task as a percentage rather than as ‘Not started’, ‘In progress’, or ‘Completed’ text.”
As already shown in previous articles, the data from Planner isn’t very user friendly. Additionally to the user information displayed as user id that needs processing, there’s also the actual task status. You might expect the words ‘Not started’, ‘In progress’ and ‘Completed’ somewhere in the data, but it’s not there. Instead you’ve got the ‘percentComplete’ field. A number. If you want the status as a text, you must convert it by yourself. And this post will show you how to do that.
Use the ‘Switch’ action
One solution is to use a variable and a ‘Switch’ action for the translation. As it’s an extra action, it’s a viable solution only if you process the tasks one by one in a loop. For example, if you export them to a SharePoint list or an Excel file.
The main piece of information is the mapping between percentage and status. If the ‘percentComplete’ is 0, the task is ‘Not started’. 100 means that the task is ‘Completed’, and anything in between (50 to be exact) is ‘In progress’. Knowing this you can ‘Initialize variable’ as a string and add a ‘Switch’ based on the ‘percentComplete’ value. Set the variable to the corresponding text, and use it as the task status later.
Use an expression
The other option is to use an expression. This is a solution you use when creating a HTML table or a csv file with the tasks. Since the ‘Create HTML table’ or ‘Create csv table’ actions process the whole array, you can’t preprocess the data as above. You must do all the processing directly in that action. And as such, you’ll need multiple if(…) expressions.
if 'percentComplete' = 100, use status 'Completed' else if 'percentComplete' = 0, use status 'Not started' otherwise use status 'In progress'
Translated to a Power Automate expression:
if( equals(item()?['percentComplete'],100), 'Completed', if(equals(item()?['percentComplete'],0), 'Not started', 'In progress') )
When you export tasks from Planner with Power Automate, you’ll receive only the completion percentage for each task. If you need text description, it’s up to you to translate them. The expression can be used anywhere, even though it’s a bit more complicated. On the other side the ‘Switch’ is easier to understand, but it can be used only in a loop.