Skip to main content
Question

How can I merge two tables in a Celonis Data Model?

  • July 2, 2026
  • 2 replies
  • 39 views

m.fleitas
Level 2
Forum|alt.badge.img+1

Hi everyone, how are you?

I'm trying to combine two tables with the same columns in a Data Model. My goal is to merge the data so I can continue adding and analyzing new information in my views.

I've tried using UNION/UNION ALL, but I haven't been able to get it to work. What is the correct way to combine two tables with the same structure in a Celonis Data Model?

Any help or guidance would be greatly appreciated. Thanks in advance!

2 replies

gagan1
Member Spotlight
Forum|alt.badge.img+5
  • Member Spotlight
  • July 2, 2026

Hi ​@m.fleitas ,

The UNION ALL is failing because you're running it in the Data Model layer. The model only defines tables and their joins, it can't append rows. You have to combine the data one step earlier, in Data Integration.

In your Data Pool, add a Transformation task and create a combined table there, then add that table to your Data Model and reload. Something like ->

DROP TABLE IF EXISTS "merged_table";
CREATE TABLE "merged_table" AS
SELECT col1, col2 FROM "schema"."table_A"
UNION ALL
SELECT col1, col2 FROM "schema"."table_B";

replace schema/table_A/table_B with your actual names

Use UNION ALL (not UNION) unless you actually want to drop duplicates. One thing that quietly breaks it: the columns must line up in count, order and data type across both selects. If a column has the same name but different type in the two tables, cast it (CAST(col AS VARCHAR)) so they match.

If you're on delta/incremental loads use CREATE TABLE like above; if you full-reload every time you can use CREATE VIEW instead, it's a bit lighter. Both can be added to the model.

DocsTransformation task best practice


abhishek.chatu14
Level 12
Forum|alt.badge.img+8

Hi ​@m.fleitas, I am guessing you are already doing what ​@gagan1  has suggested can you share what error you are getting while preforming the UNION/UNION ALL