One of the most essential tools for making computers work for you is conditional logic—”if this, then that” logic. It’s simple yet incredibly powerful, and much of how computers function today relies on this concept. In this blog post, we’ll explore how to use conditional logic in Power Automate to add more sophistication to your workflows, particularly those involving Excel tasks. We’ll focus on using an Excel table to trigger emails based on the status of a project. To get started, download the exercise file below:
In this dataset, you’ll find a list of projects and their respective owners. Our objective is to reach out to the project owner each week via email to request a status update.
For one of the delayed projects, I recommend using your real email address. This way, you can test if the process works as expected, since the other email addresses are (hopefully!) fake.
Next, upload the test workbook to your OneDrive account with Power Automate access. Then, head over to make.powerautomate.com to set up the flow. We’ll use Copilot to help build the skeleton of this flow. Under the “Create your automation with Copilot” section, input the following prompt:
Create a flow for every Monday morning at 9am. First, list the the rows of my power-automate-conditional-flows-demo.xlsx Excel table. For any project where Status = “Delayed,” send an email to that project’s owner asking for a status update.
After clicking “Generate,” you should see Power Automate suggest a flow similar to the one below. Keep in mind that as a generative AI tool, Copilot’s outputs can vary, so you may receive something a bit different.
This looks like a solid starting point, so I’ll confirm that it’s what I want and load it into a new flow. The first step is refining how the recurrence works. Click into this step to adjust the parameters. I’ll set it to run once a week at 9 a.m. Eastern Time on Mondays. Feel free to change these settings to match your time zone or make any other adjustments you’d like.
The next step is to list all the rows in our Excel table. Click on this step within the flow to ensure it’s pointing to the correct Excel workbook and the appropriate Excel table.
The next step is labeled “Foreach.” If you’re familiar with computer science logic, this essentially functions as a for loop. We’ll be going through each row in the Excel table and performing an action. Specifically, we need to check if a certain condition is met. Click on the “Condition” part of the flow to set this up.
We’ll use the value from the Status column to determine the next action. If the project status is “Delayed,” that’s when we’ll trigger the email—otherwise, we don’t need to do anything. Set this up under the parameters of the Condition flow. Remember to enclose any hard-coded strings in quotations, and note that Power Fx is case-sensitive, so it will look for “Delayed” exactly.
Make sure you’re using dynamically linked content from the previous workbook—you’ll recognize it by the little Excel icon next to “Status.” Also, double-check that the column name matches exactly what’s in the workbook, as Copilot may sometimes rename columns.
The next step is to take action only when that condition is met. We’ll send an email, but only when the condition is True. If Power Automate didn’t set this up correctly, adjust it to ensure the “Send an email” step is directly under the True condition.
Click into this flow to configure the email details. Make sure the dynamic content you use matches exactly with the column names in your workbook. I’ll be sending the email to the relevant project owner, and I’ll include dynamic content for both the Project Name and Project ID.
Awesome work! Now it’s time to test your flow.
First, save it, then head to the upper taskbar of the Power Automate interface and select the option to test it. Manually trigger the flow this time so you don’t have to wait until Monday morning. Once everything is set, run the test. If successful, you should see a “Test succeeded” status in the Run history.
At this point, it’s a good idea to use an actual email address in the recipient list so you can verify that everything is working correctly. This way, you can check your inbox and confirm the flow is functioning as expected.
On the flip side, you’ll notice that only the project owner of the delayed project receives an email (which may bounce back if it’s a test address). The others don’t get emails since their projects are on track. How cool is that?
In this blog post, we explored how to use if-then logic in Power Automate to create flows based on conditional statements, such as sending emails only to those with delayed projects.
What questions do you have about using conditional logic in Power Automate or how it can improve your Excel workflows? Drop them in the comments!
Leave a Reply