๐ Power Automate Expressions Exercises Guide
Here's a structured guide to expressions exercises in Power Automate, designed to help you master data manipulation, logic building, and workflow optimization. The exercises are categorized by difficulty and include practical examples from search results, with key insights and citations for deeper learning:
Beginner Exercises
- Objective: Learn foundational expression syntax and simple data transformations.
-
๐ค Display Your Name and Date
- Create a flow that outputs your name and the current date using
concat()
andutcNow()
². - Example:
@concat('Your Name: John | Date: ', formatDateTime(utcNow(), 'yyyy-MM-dd'))
- Create a flow that outputs your name and the current date using
-
๐ Filter SharePoint Lists
- Use
filter()
to extract items from a SharePoint list where the "Category" equals "Search Engines" ². - Expression:
@equals(item()?['Category'], 'Search Engine')
- Use
-
๐ง List Outlook Inbox Emails
- Retrieve all emails in your Outlook inbox using
triggerBody()
and display subjects withconcat()
².
- Retrieve all emails in your Outlook inbox using
Intermediate Exercises
- Objective: Use expressions for conditional logic and data processing.
-
๐ฉ Conditional Email Flagging
- Trigger a flow when an email is flagged in Outlook. Use
if()
to check the flagged status and send a summary ⁴. - Example:
@if(equals(triggerBody()?['IsFlagged'], true, 'Flagged for review', 'No action')
- Trigger a flow when an email is flagged in Outlook. Use
-
๐ฐ Validate Payment Deadlines
- Compare due dates with
less()
andaddDays()
to send reminders for unpaid invoices ⁴. - Expression:
@and(greater(item()?['Due'], item()?['Paid']), less(item()?['DueDate'], addDays(utcNow(), 1)))
- Compare due dates with
-
๐ Dynamic File Management
- List files (excluding folders) in OneDrive using
empty()
andendsWith()
to filter results ²¹⁰.
- List files (excluding folders) in OneDrive using
Advanced Exercises
- Objective: Tackle complex data structures and nested functions.
-
๐ฆ JSON Parsing
- Extract nested data from a JSON response using
body()
and handle null values withcoalesce()
³⁵. - Example:
@coalesce(body('Parse_JSON')?['customer'][0]?['accountDescription'], 'N/A')
- Extract nested data from a JSON response using
-
๐จ Error Handling with Try-Catch
- Build a flow to add items to a SharePoint list using
try
andcatch
clauses withactions()
for error logging ²⁵.
- Build a flow to add items to a SharePoint list using
-
⏱️ Time-Based Calculations
- Calculate the difference in seconds between two dates using
ticks()
anddiv()
⁵: - Expression:
@div(sub(ticks(utcNow()), ticks(item()?['Created']), 10000000)
- Calculate the difference in seconds between two dates using
-
๐ฌ Adaptive Cards for Teams
- Design an adaptive card for Teams that dynamically populates options using
concat()
andsplit()
².
- Design an adaptive card for Teams that dynamically populates options using
Pro Tips for Success
- ๐ Use Text Editors: Write complex expressions in Notepad++ or VS Code for readability, then paste them into Power Automate ³⁵.
- ๐งช Test with Compose: Validate expressions step-by-step using the
Compose
action ⁷. - ๐ Leverage Dynamic Content: Avoid hardcoding values by referencing outputs from previous steps (e.g.,
triggerBody()?['ID']
) ⁵.
Recommended Resources
- ๐ Microsoft Learn Modules: Deepen your understanding with official guides ¹.
- ๐จ๐ซ Udemy Course: Enroll in "Master Microsoft Power Automate Expressions in 2 Hours" for hands-on JSON parsing and data operations ¹¹.
- ๐ฆ Wise Owl Exercises: Practice 21+ free exercises covering loops, error handling, and Teams integration ².
By progressing through these exercises, you’ll gain confidence in using expressions to automate complex workflows efficiently. Let me know if you need further clarification or examples! ๐
๐ Additional Power Automate Expression Exercises
Here are additional Power Automate expression exercises to deepen your skills, categorized by complexity and use case. These exercises incorporate advanced functions, real-world scenarios, and integration with Microsoft services:
๐งฐ Advanced Data Manipulation Exercises
- ๐ฆ Dynamic JSON Parsing
- Scenario: Extract nested values from a JSON API response (e.g.,
body('Parse_JSON')?['customer']['address']['city']
) and handle null values usingcoalesce()
⁵¹⁰. - Steps:
- Use
HTTP Request
to fetch JSON data. - Parse with
Parse JSON
action. - Build expressions to retrieve nested values and replace nulls with "N/A".
- Use
- Scenario: Extract nested values from a JSON API response (e.g.,
- ๐ URI Component Encoding
- Scenario: Encode a user-input URL for API compatibility using
encodeUriComponent()
. - Expression:
@encodeUriComponent(triggerBody()?['UserURL'])
- Use Case: Safely pass URLs in API requests ¹⁰.
- Scenario: Encode a user-input URL for API compatibility using
- ๐
Date/Time Zone Conversion
- Scenario: Convert a SharePoint timestamp to a user’s local time zone using
convertTimeZone()
. - Expression:
:cite[7]@convertTimeZone(item()?['Created'], 'UTC', 'Eastern Standard Time', 'dd-MM-yyyy hh:mm tt')
- Scenario: Convert a SharePoint timestamp to a user’s local time zone using
๐จ Error Handling & Validation
- ๐ Try-Catch for SharePoint List Updates
- Scenario: Safely add items to a SharePoint list and log errors if the action fails ³.
- Steps:
- Use
Create Item
(SharePoint) in aScope
block. - Add a
Catch
block to send an email alert on failure.
- Use
- Key Function:
outputs('Scope_Name')?['status']
to check success/failure.
- ๐ข Data Type Validation
- Scenario: Ensure user-submitted age is an integer using
isInt()
before processing. - Expression:
:cite[6]@if(isInt(triggerBody()?['Age']), 'Valid', 'Invalid')
- Scenario: Ensure user-submitted age is an integer using
๐ค Integration & Automation Scenarios
- ๐ง๐ค๐ง Microsoft Graph User Lookup
- Scenario: Fetch all Microsoft 365 users via HTTP request to Microsoft Graph API.
- Expression:
@body('HTTP_Request')?['value']
- Use Case: Automate user directory sync ³.
- ๐ Power BI Report Trigger
- Scenario: Add a button to a Power BI report that triggers a flow to email selected data.
- Key Step: Use
triggerOutputs()?['selectedPizzas']
to capture user selections ³.
- ๐ฌ Teams Adaptive Card Ordering System
- Scenario: Create a Teams adaptive card for lunch orders with dynamic dropdowns using
concat()
andsplit()
³¹³. - Example:
@concat('Main Course: ', split(triggerBody()?['Order'], ',')[0])
- Scenario: Create a Teams adaptive card for lunch orders with dynamic dropdowns using
✨ Data Formatting & Transformation
- ๐ข Format by Example for Numbers
- Scenario: Convert "5" to "005" using
Format data by example
(old designer) for legacy system compatibility ¹³. - Steps:
- Provide input/output examples (e.g., "1" → "001").
- Power Automate auto-generates
formatNumber()
expressions.
- Scenario: Convert "5" to "005" using
- ๐ Multi-Language Date Formatting
- Scenario: Format a date as "2025ๅนด04ๆ07ๆฅ" for Japanese users using
formatDateTime(utcNow(), 'yyyyๅนดMMๆddๆฅ', 'ja-JP')
¹⁰.
- Scenario: Format a date as "2025ๅนด04ๆ07ๆฅ" for Japanese users using
⚙️ Optimization & Best Practices
- ✂️ Array Batch Processing
- Scenario: Split a 1,000-item array into chunks of 100 using
chunk()
to avoid API rate limits ⁹. - Expression:
@chunk(body('Get_Items'), 100)
- Scenario: Split a 1,000-item array into chunks of 100 using
- ๐ Efficient Filtering with
intersection()
- Scenario: Find common customers between two CRM systems using
intersection(array1, array2)
¹⁰.
- Scenario: Find common customers between two CRM systems using
๐ Creative Use Cases
- ๐ง๐ค๐ง Random Team Assignments
- Scenario: Assign employees to random groups using
rand()
andtake()
: - Expression:
:cite[7]@take(shuffle(variables('Employees')), 5)
- Scenario: Assign employees to random groups using
- ๐ข Social Media Post Scheduler
- Scenario: Auto-post to LinkedIn at optimal times using
addHours(utcNow(), 8)
for time zone adjustments ¹⁰.
- Scenario: Auto-post to LinkedIn at optimal times using
๐ Resources for Further Practice
- ๐ฆ Wise Owl’s 21+ Exercises: Try advanced tasks like error handling, Teams integration, or Power BI automation ³⁴.
- ๐จ๐ซ Microsoft Learn Modules: Master functions like
ticks()
for timestamp comparisons ordecodeBase64()
for file processing ¹⁵. - ๐ Expression Cheat Sheets: Refer to categorized function lists for quick syntax reminders ¹⁰.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.