Introduction
In Power Automate, the Compose action plays a crucial role in handling data within a flow. It allows you to store values—such as text, numbers, arrays, or complex JSON structures—temporarily, making them easy to reference and reuse. Whether you’re simplifying expressions, storing intermediate results, or preparing data for further actions, Compose provides a clean and efficient way to manage data logic. This is especially useful when dealing with structured outputs from services like HTTP requests or databases, where you need to extract and manipulate specific fields without repeatedly writing complex expressions.
Compose action
The Compose action in Power Automate is used to create and store data temporarily within a flow. It can be used to build or manipulate structured data like JSON, strings, numbers, or arrays, and then reference that data later in the flow without recalculating or repeating logic.
Why Compose is Most Commonly Used:
-
Simplify Expressions
You can write a long expression once in Compose (like concat(...), formatDateTime(...), etc.), give it a name, and reference it later. This improves readability and makes your flow easier to maintain.
Example
formatDateTime(utcNow(), 'yyyy-MM-dd')
-
Hold Intermediate Values
Store intermediate results between actions (like extracted text, filtered data, or calculated totals).
-
Build JSON or Arrays
Use Compose to build structured data that will be passed to APIs, loops, or other systems.
-
Debug and Inspect Values
Since Compose outputs are visible in run history, it’s a quick way to test and see what your expression returns.
Example JSON Data
{
"body": {
"headers": [
{
"sha1": "08f96a6ac4300",
"headers": [
{
"Subject": "You missed a VM= | Transcription Available Play Now 02min57se= 3pm|Friday-February-2024 12:21 PM"
},
{
"Message-Id": "<[email protected]>"
},
{
"Content-Transfer-Encoding": "7bit"
}
],
"filename": "rawHeaders.txt",
"sha256": "89525511f796c492eb"
}
],
"addresses": {
"to": [
"jeom"
]
},
"links": [],
"phishml": {
"confidence_spam": "0.0002689999237190932",
"confidence_clean": "0.00001319524653808912",
"category": "threat",
"confidence_threat": "0.9997478127479553"
},
"history": [
{
"date": "2024-02-16T16:08:21-05:00",
"events": {
"phishrip_started": {
"queried_fields": [
"from",
"subject"
],
"time_range": {
"start_time": "2024-02-15T16:08:15-05:00",
"end_time": "2024-02-16 21:08:15 +0000"
},
"quarantine": "true",
"id": "7dd22796-c400-4b9f-9c74-3f198272a36d",
"status": "processing"
}
},
"causer_name": "Threat Email Notification for Reporter"
},
{
"date": "2024-02-16T16:08:15-05:00",
"trigger_name": "One of three different names here",
"causer_type": "Action",
"event_type": "other",
"trigger_type": "User",
"events": {
"emails": [
{
"action_email_id": "c4ba53c9-8932-40a7-a347-f0cb74d04f15",
"to": [
""
],
"email": "Threat Email Notification for Reporter",
"status": null
}
],
"changed_fields": {
"action_status": [
"received",
"resolved"
]
}
},
"causer_name": "Threat Email Notification for Reporter"
},
{
"date": "2024-02-16T16:07:56-05:00",
"trigger_name": null,
"causer_type": "User",
"event_type": "other",
"trigger_type": null,
"events": {
"changed_fields": {
"viewed": [
false,
true
]
}
},
"causer_name": "NAME HERE"
},
{
"date": "2024-02-16T15:22:35-05:00",
"trigger_name": null,
"causer_type": "Action",
"event_type": "other",
"trigger_type": null,
"events": {
"emails": [
{
"action_email_id": "0ebd75cc-23ea-4f91-8459-023f81e6c891",
"to": [
""
],
"email": "Threat Email Notification for Admin",
"status": null
}
],
"tags": {
"added": [
"MANUAL"
]
},
"changed_fields": {
"severity": [
"unknown_severity",
"critical"
],
"category": [
"unknown",
"threat"
]
}
},
"causer_name": "Threat Notification for Admin"
},
{
"date": "2024-02-16T15:22:34-05:00",
"trigger_name": null,
"causer_type": "Rule",
"event_type": "other",
"trigger_type": null,
"events": {
"tags": {
"added": [
"KB4:SPF_PASS"
]
},
"changed_fields": {
"pipeline_status": [
"processing",
"processed"
]
}
},
"causer_name": "KB4:URGENCY"
},
{
"date": "2024-02-16T15:22:26-05:00",
"trigger_name": null,
"causer_type": "Intert",
"event_type": "other",
"trigger_type": null,
"events": {
"report": {
"name": "VirusTotal",
"results": [
{
"field": "attachment",
"value": "JPQN.png"
},
{
"field": "autoscan",
"value": "SHA-256 not found."
}
]
},
"tags": {
"removed": [
"VT_PENDING"
],
"added": [
"VT_HASH_NOT_FOUND"
]
}
},
"causer_name": "VirusTotal"
},
{
"date": "2024-02-16T15:22:22-05:00",
"trigger_name": null,
"causer_type": "Integrations::PhishMl::Report",
"event_type": "other",
"trigger_type": null,
"events": {
"report": {
"name": "Phish ML",
"results": [
{
"field": "clean",
"value": "0.00"
},
{
"field": "spam",
"value": "0.03"
},
{
"field": "threat",
"value": "99.97"
}
]
},
"tags": {
"added": [
"PML:THREAT"
]
}
},
"causer_name": "Phish ML"
},
{
"date": "2024-02-16T15:22:10-05:00",
"events": {
"part": {
"name": "JPQN.png"
}
},
"causer_name": null
},
{
"date": "2024-02-16T15:22:10-05:00",
"causer_name": null
}
],
"bad_links": [],
"tags": [
"SUCCESS_TAG"
]
}
}
For example, if you're receiving this data from a source like an HTTP call or a database in plain text or JSON format, you’ll first need to parse it to access specific values like the subject. In such cases, the Compose action is very helpful — you can use it to temporarily hold the parsed data or just extract the Subject using an expression, making it easier to reuse later in your flow.
I will hold JSON value in the compose action:
![]()
We can also pass composed value in a variable; here I am using ‘varObject’ to store composed output value -
![]()
Now, if I want to get the first header subject value, I can use low low-code/no-code expression to get the value -
variables('varObject')['body']['headers'][0]['headers'][0]['Subject']
Which we can assign to a variable like this:
![]()
And we will be able to extract the subject value in the variable ’varSubject‘.
Conclusion
The Compose action in Power Automate is a powerful yet simple tool that helps streamline flows by reducing complexity and improving maintainability. Whether you're working with raw JSON, intermediate results, or dynamic expressions, Compose allows you to hold, inspect, and reuse data efficiently without redundancy. In scenarios involving nested JSON—like extracting the ‘Subject’ line from email headers, it enables a clean, low-code approach to access values quickly and assign them for further use. By leveraging Compose strategically, you not only simplify your flow logic but also make debugging and future updates much easier.