# Merging event logs

> :::tip
If you have multiple Event tables, these can be added to the data model one-by-one and they are merged automatically. Check out [Viewing and editing the data model](https://docs.uipath.com/process-mining/automation-suite/2024.10/user-guide/data-models#viewing-and-editing-the-data-model) for more information on how to add tables. Alternatively, you can manually merge Event tables using the following queries.
:::

:::tip
If you have multiple Event tables, these can be added to the data model one-by-one and they are merged automatically. Check out [Viewing and editing the data model](https://docs.uipath.com/process-mining/automation-suite/2024.10/user-guide/data-models#viewing-and-editing-the-data-model) for more information on how to add tables. Alternatively, you can manually merge Event tables using the following queries.
:::

If your event log is split over multiple event log files, you can merge the event logs into a single event log in Data transformations.

:::note
To merge multiple event logs, the **Case_ID** should point to the same object for all files. For example, all Case IDs are pointing to Sales Order IDs., such that **Case_ID** points to the same table for all event logs.
:::

1. Create a new app, based on the **Event log** app template.
2. Use the **Upload data** option in the **Selecting the Data Source** step, and select the event log files you want to merge.
3. Continue the **Create new app** wizard to create the app and to transform the data. The data run will fail and the Application status will show **Run failed**.
4. Select **View log** to view the log file.

An error message displays indicating that the expected file is not found.

   ![Error message](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-error-message-368873-bfb1632c-1097dffb.webp)
5. Go to the [Data transformations](https://docs.uipath.com/process-mining/automation-suite/2024.10/user-guide/data-transformations#data-transformations-editor) editor.
6. For each input file:
   1. Create a `.sql` file with the same contents as the already available `Event_log_input.sql`.

   ![Event_log_input.sql file](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-event-log-input-sql-file-368884-1fe2034b-20fef9ed.webp)
   2. Adjust the file to select the required input fields and type cast them correctly.
   3. Add the name of the new source tables to `sources.yml`.

Now all new input files can be combined into a single event log.
      :::note
      Make sure that the input files all have the exact same set of fields.
      :::
7. Select the `Event_log_input.sql` file and replace the contents with:
   ```
   -- The following code merges 3 input tables.
   select * from {{ ref('Event_log_input_1') }}
   union all
   select * from {{ ref('Event_log_input_2') }}
   union all
   select * from {{ ref('Event_log_input_3') }}
   ```

![Event_log_input.sql file](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-event-log-input-sql-file-368889-5ad1a96c-f583e14e.webp)

   :::note
   Adjust the code to match the names of the input tables needed.
   :::
8. Select **Apply to dashboards** to run the data transformations and make the resulting table available for use in the dashboards.
