Power Automate Desktop Variables: Strings, Numbers, Booleans, Lists

Power Automate Desktop – Variables and Operations

In Power Automate Desktop, you can create different types of variables using the UI and assign values to them. For example:

  • Text variable → value: sunil
  • Number variable → value: 10
  • Boolean variable → value: True
  • List 1 → add items: sunil, anil, zeshan, nithesh
  • List 2 → add items: sunil, sachin, 20

Once variables are created, you can perform actions to modify and manage their values.

Variable Operations Overview

Number operations: Increase or decrease numeric values and round decimal numbers to a specific number of digits.
Boolean variable: Holds True or False values for conditional checks.
List operations: Perform advanced operations on lists of data.

List Operations Explanation

Sort List: Arranges items in alphabetical or numeric order.
Shuffle List: Randomly changes the order of list items.
Reverse List: Flips the list order from last to first.
Merge Lists: Combines two lists into one.
Find Common Items: Extracts items that are present in both lists.
Remove Duplicates: Deletes repeated items, keeping only unique values.
Subtract Lists: Returns items that are in List 1 but not in List 2.
Remove Item: Deletes a specific value from the list.
Clear List: Removes all items, leaving the list empty.

PAD Script

# setting string value
SET vartext TO $'''sunil'''
# setting number value
SET varnumber TO 10
# increment number
Variables.IncreaseVariable Value: varnumber IncrementValue: 1
# decrement number by 2
Variables.DecreaseVariable Value: varnumber DecrementValue: 2
# generate random numbers
Variables.GenerateRandomNumber.RandomNumber MinimumValue: 0 MaximumValue: 100 RandomNumber=> RandomNumber
/# truncate number ex(num=99.9999999999995)
1. integer part  = 99
2. decimal part = 0.9999999999995
3. round(3) 100.000#/
Variables.TruncateNumber.RoundNumber Number: 99.999999995 DecimalPlaces: 3 Result=> TruncatedValue
# setting boolean value  enclosed with %
SET varboolean TO True
# creating list
Variables.CreateNewList List=> varList
Variables.AddItemToList Item: $'''sunil''' List: varList
Variables.AddItemToList Item: $'''anil''' List: varList
Variables.AddItemToList Item: $'''zeshan''' List: varList
Variables.AddItemToList Item: $'''nithesh''' List: varList
# creating second list
Variables.CreateNewList List=> varList2
Variables.AddItemToList Item: $'''sunil''' List: varList2
Variables.AddItemToList Item: $'''sachin''' List: varList2
Variables.AddItemToList Item: 20 List: varList2
/# list operations
1. sort list (use items of same type)#/
Variables.SortList.SortList List: varList
/# list operations
2.shuffle list #/
Variables.ShuffleList List: varList2
/# list operations
3. reverse the order of a list#/
Variables.ReverseList List: varList
/# list operations
3. merge list - merge two list in to one#/
Variables.MergeLists FirstList: varList SecondList: varList2 OutputList=> varmergedList
/# list operations
4. find common elements in a list#/
Variables.FindCommonListItems FirstList: varList SecondList: varList2 OutputList=> IntersectionList
/# list operations
5. remove duplicates from list#/
Variables.RemoveDuplicateItemsFromList List: varmergedList IgnoreCase: False
/# list operations
6. item present in list 1 not in list 2  (ignore same item from list 1)#/
Variables.SubtractLists FirstList: varList SecondList: varList2 OutputList=> ListDifference
/# list operations
7. remove item from a list#/
Variables.RemoveItemFromList.RemoveItemFromListByValue Item: $'''anil''' ItemMatchAllOccurrences: True List: ListDifference
/# list operations
8. clear whole list#/
Variables.ClearList List: varList
  

Copy and paste the above code into your Power Automate Desktop designer to test all variable operations.

Comments

Popular posts from this blog

Part 1: Creating Code Apps in Power Apps - A step-by-step guide (with real errors I faced & how I fixed them)

Calling Microsoft Graph API from Power Automate Using Azure App Services – Step-by-Step Guide

Step-by-Step Guide: Power Automate Custom Connector Using Graph API from Azure App Service