Union Tables in PowerBI

You can use UNION formula to union tables. You can use only table names but all field name and column count must be same. Also PowerBI arranges the field sort order and can do disappointing results.

Transactions = UNION(LedgerTransactions,LegacyLedgerTransactions,BudgetTransactions)

Instead, you can select your tables and columns. Also you can filter your tables before joining.

Here is the simple code:

Transactions = 

UNION(
SELECTCOLUMNS(filter(BudgetTransactions,BudgetTransactions[BudgetCode] = "2019B") ,
"MainAccount",BudgetTransactions[MainAccount],
"CostCenter",BudgetTransactions[CostCenter],
"CostDefinition",BudgetTransactions[CostDefinition],
"Balance",BudgetTransactions[balance],
"Code",BudgetTransactions[Code],
"Date",BudgetTransactions[Date]
),
SELECTCOLUMNS(LegacyLedgerTransactions,
"MainAccount",LegacyLedgerTransactions[MainAccount],
"CostCenter",LegacyLedgerTransactions[CostCenter],
"CostDefinition",LegacyLedgerTransactions[CostDefinition],
"Balance",LegacyLedgerTransactions[balance],
"Code",LegacyLedgerTransactions[Code],
"Date",LegacyLedgerTransactions[Date]
),
SELECTCOLUMNS(LedgerTransactions,
"MainAccount",LedgerTransactions[MainAccount],
"CostCenter",LedgerTransactions[CostCenter],
"CostDefinition",LedgerTransactions[CostDefinition],
"Balance",LedgerTransactions[balance],
"Code",LedgerTransactions[Code],
"Date",LedgerTransactions[Date]
),
SELECTCOLUMNS(LegacyBudgetTransactions,
"MainAccount",LegacyBudgetTransactions[MainAccount],
"CostCenter",LegacyBudgetTransactions[CostCenter],
"CostDefinition",LegacyBudgetTransactions[CostDefinition],
"Balance",LegacyBudgetTransactions[balance],
"Code",LegacyBudgetTransactions[Code],
"Date",LegacyBudgetTransactions[Date]
)

)

Leave a Reply

Your email address will not be published. Required fields are marked *