Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
Anonymous
Not applicable

power bi union

I have a challenge that I need help with.

 

I have a power bi semantic model that contains information re orders, sales, sales contracts, purchase contracts, inventory etc in seperate fact tables.

 

the source data is in a ms analysis services database.  

 

I want to build a report that looks like this.

 

location     products         type                             quantity kg

toronto      abc                  sales                           100

toronto      abc                  sales contracts            250

sales total toronto                                                350

toronto      abc                   purchase contracts    300

toronto      abc                   inventory                   75

ownership total toronto                                       375

chicago      abc                  sales                           200

chicago      abc                  sales contracts            250

sales total chicago                                                450

chicago      abc                   purchase contracts    300

chicago      abc                   inventory                   25

ownership total chicago                                       325

 

it appears dax would union the base tables together and since they look nothing alike this would be a problem

since the source data is in analysis services, this I belive causes a problem for power query.

 

any ideas would be appreciated

 

2 ACCEPTED SOLUTIONS
bhanu_gautam
Super User
Super User

@Anonymous , 

Create a calculated table for each fact table with a common structure. For example:

DAX
SalesTable =
SELECTCOLUMNS (
'Sales',
"Location", 'Sales'[Location],
"Product", 'Sales'[Product],
"Type", "Sales",
"Quantity", 'Sales'[Quantity]
)

SalesContractsTable =
SELECTCOLUMNS (
'SalesContracts',
"Location", 'SalesContracts'[Location],
"Product", 'SalesContracts'[Product],
"Type", "Sales Contracts",
"Quantity", 'SalesContracts'[Quantity]
)

PurchaseContractsTable =
SELECTCOLUMNS (
'PurchaseContracts',
"Location", 'PurchaseContracts'[Location],
"Product", 'PurchaseContracts'[Product],
"Type", "Purchase Contracts",
"Quantity", 'PurchaseContracts'[Quantity]
)

InventoryTable =
SELECTCOLUMNS (
'Inventory',
"Location", 'Inventory'[Location],
"Product", 'Inventory'[Product],
"Type", "Inventory",
"Quantity", 'Inventory'[Quantity]
)

 

 

Create a new table that unions all the calculated tables:

DAX
CombinedTable =
UNION (
SalesTable,
SalesContractsTable,
PurchaseContractsTable,
InventoryTable
)

 

Create measures to calculate the totals for sales and ownership:

DAX
SalesTotal =
CALCULATE (
SUM ( CombinedTable[Quantity] ),
CombinedTable[Type] IN { "Sales", "Sales Contracts" }
)

OwnershipTotal =
CALCULATE (
SUM ( CombinedTable[Quantity] ),
CombinedTable[Type] IN { "Purchase Contracts", "Inventory" }
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

Anonymous
Not applicable

Hi @Anonymous ,

Did the reply bhanu_gautam offered help you solve the problem, if it helps, you can consider to accept it as a solution so that more user can refer to, or if you have other problems, you can offer some information so that can provide more suggestion for you.

Thank you for your understanding.

Best regards,

Lucy Chen

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I am not sure how I use these new measures in the matrix report I am building

Create measures to calculate the totals for sales and ownership:

Anonymous
Not applicable

Hi @Anonymous ,

Did the reply bhanu_gautam offered help you solve the problem, if it helps, you can consider to accept it as a solution so that more user can refer to, or if you have other problems, you can offer some information so that can provide more suggestion for you.

Thank you for your understanding.

Best regards,

Lucy Chen

bhanu_gautam
Super User
Super User

@Anonymous , 

Create a calculated table for each fact table with a common structure. For example:

DAX
SalesTable =
SELECTCOLUMNS (
'Sales',
"Location", 'Sales'[Location],
"Product", 'Sales'[Product],
"Type", "Sales",
"Quantity", 'Sales'[Quantity]
)

SalesContractsTable =
SELECTCOLUMNS (
'SalesContracts',
"Location", 'SalesContracts'[Location],
"Product", 'SalesContracts'[Product],
"Type", "Sales Contracts",
"Quantity", 'SalesContracts'[Quantity]
)

PurchaseContractsTable =
SELECTCOLUMNS (
'PurchaseContracts',
"Location", 'PurchaseContracts'[Location],
"Product", 'PurchaseContracts'[Product],
"Type", "Purchase Contracts",
"Quantity", 'PurchaseContracts'[Quantity]
)

InventoryTable =
SELECTCOLUMNS (
'Inventory',
"Location", 'Inventory'[Location],
"Product", 'Inventory'[Product],
"Type", "Inventory",
"Quantity", 'Inventory'[Quantity]
)

 

 

Create a new table that unions all the calculated tables:

DAX
CombinedTable =
UNION (
SalesTable,
SalesContractsTable,
PurchaseContractsTable,
InventoryTable
)

 

Create measures to calculate the totals for sales and ownership:

DAX
SalesTotal =
CALCULATE (
SUM ( CombinedTable[Quantity] ),
CombinedTable[Type] IN { "Sales", "Sales Contracts" }
)

OwnershipTotal =
CALCULATE (
SUM ( CombinedTable[Quantity] ),
CombinedTable[Type] IN { "Purchase Contracts", "Inventory" }
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.