> For the complete documentation index, see [llms.txt](https://documentation.astera.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.astera.com/astera-data-stack-v10/faqs/workflows/can-i-perform-an-action-based-on-whether-a-file-has-data.md).

# Can I perform an action based on whether a file has data?

Yes, you can perform workflow actions based on the decision whether a file has data or not. This can be done using an Aggregate object in a dataflow to calculate record count and pass it as an output variable in the workflow. &#x20;

Dataflow:

<figure><img src="https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FbCnnFxX0wCwWcWMBnZ6p%2FFileHasData-Dataflow.png?alt=media&amp;token=4e011f3a-3b21-43b4-8966-88916e7b56c8" alt=""><figcaption></figcaption></figure>

Workflow:

<figure><img src="https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F2MSv1Pc90GCHkwzqDayE%2FFileHasData-Workflow.png?alt=media&amp;token=86f85cd5-b213-4b86-89bf-a51d92bb1c42" alt=""><figcaption></figcaption></figure>

The following steps allow you to perform workflow actions based on whether a file has records or not:&#x20;

* In the dataflow, map a source field to an Aggregate transformation, setting the aggregate function for that field to Count.&#x20;
* Then, map that field from the Aggregate transformation to an Expression where you would set this field to a variable.&#x20;
* Define an output variable for this field in a local variables object. &#x20;
* In your workflow, configure a Run Dataflow Task for your dataflow, the output variable will appear in the object. &#x20;
* Place a Decision task after the Run Dataflow task. &#x20;
* Specify the condition that Count variable should be greater than 0. &#x20;
* Map the Yes port to the task that should be performed if the file has records. &#x20;
* Map the No port to the task that should be performed if the file does not have records. Either of these ports can be left unmapped if you don’t want a task to be performed for that decision outcome. &#x20;

> Note: This process might impact performance when handling large datasets. Although we only need to determine if there are any records (0 or more), the system will process the entire dataset.&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://documentation.astera.com/astera-data-stack-v10/faqs/workflows/can-i-perform-an-action-based-on-whether-a-file-has-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
