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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Syndicate_Admin
Administrator
Administrator

Calculating costs between two tables

Hello

I want to calculate the total loss/theft cost by multiplying the incident units by the average unit cost of sales of the same Product–POS–Date.

The FactSales (has costs per day) and FactIncident (has reported units) tables are not directly related to each other, but both are related to DimProduct (ProductID) and POS/Branch (BranchID).

Both have the Date column (at the day level).

Relevant columns: ProductID, BranchID (POS), Date.

The following are the measurements I am using:

Total Cost =
SUMX(
SUMMARIZE(
FactIncident,
FactIncident[ProductID],
FactIncident[Date],
FactIncident[POS]
),
[Incident Units] * [Average Unit Cost]
)

Incident Units =
SUM ( FactIncident [QuantityUnits] )

Average Unit Cost =
DIVIDE ( [Cost of Sales], [Sale Units] )


Cost of Sales =
SUM ( FactSales[cost] ) )

Selling Units =
SUM ( FactSales[SaleUnits] )

The problem I'm having is that when I calculate the data, it is not generating the total, although if I check it by row the data is fine.

I share with you the semantic model.

I thank you for your help or guidance on how I should generate this measurement between different tables.

POS Note = BranchID

grgilardi_0-1754969656885.png

1 ACCEPTED SOLUTION
v-pnaroju-msft
Community Support
Community Support

Thankyou, @pankajnamekar25, for your response.

Hi Syndicate_Admin,

We appreciate your inquiry submitted through the Microsoft Fabric Community Forum.

We aggregated sales data to calculate the average cost per product, branch, and date. For each incident row, we located the corresponding average cost and then multiplied the incident units by that average cost. Finally, we summed these values to obtain the total.

Please find attached a screenshot and a sample PBIX file that may assist in resolving the issue:

vpnarojumsft_0-1754990160265.png

We hope the information provided helps to address your concern. Should you have any further queries, please feel free to contact the Microsoft Fabric Community.

Thank you.

View solution in original post

2 REPLIES 2
v-pnaroju-msft
Community Support
Community Support

Thankyou, @pankajnamekar25, for your response.

Hi Syndicate_Admin,

We appreciate your inquiry submitted through the Microsoft Fabric Community Forum.

We aggregated sales data to calculate the average cost per product, branch, and date. For each incident row, we located the corresponding average cost and then multiplied the incident units by that average cost. Finally, we summed these values to obtain the total.

Please find attached a screenshot and a sample PBIX file that may assist in resolving the issue:

vpnarojumsft_0-1754990160265.png

We hope the information provided helps to address your concern. Should you have any further queries, please feel free to contact the Microsoft Fabric Community.

Thank you.

pankajnamekar25
Super User
Super User

Hello @Syndicate_Admin 

 

Try this DAX

Total Cost =
SUMX (
FactIncident,
FactIncident[QuantityUnits] *
CALCULATE (
DIVIDE (
SUM ( FactSales[Cost] ),
SUM ( FactSales[SaleUnits] )
),
TREATAS ( VALUES ( FactIncident[ProductID] ), FactSales[ProductID] ),
TREATAS ( VALUES ( FactIncident[POS] ), FactSales[BranchID] ),
TREATAS ( VALUES ( FactIncident[Date] ), FactSales[Date] )
)
)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.