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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Trebla
Regular Visitor

Calculating inventory and consumption based on valid contracts and consumption

Hi guys,

I've been trying to tackle this problem for a few days now and can't seem to wrap my head around it. I tried to provide examples of all the tables I'm working with. 

Setup:

Contract (Fact table), which tell how many and which contracts are valid on certain date and which and their product ID (there are multiple types of contracts/products). 

Unique contract IDStart date (dd.mm.yyyy)End date (dd.mm.yyyy)Product idInventory type
11.7.20231.7.2023151
21.6.202331.12.2023122
31.5.202331.9.2023151

 

These contracts, while they are valid, consume inventory. The inventory is filled every once in a while and that info is received from another table (inventoryfills_fact)

DateAmount of units Price per unit ($)Inventory type
10.5.2023250151
5.6.202310012,52

 

The amount of consumption is received from another table (consumption_dim)

Product IDConsumption per monthconsumption per day (month / 30 )Inventory type consume price ($)
12602220
15303118

This is a dimension table 

I also have a basic calendar table with dates, year, month number etc that is connected to to both inventoryfills and Contract with one to many-relationship.  

 

Desired outcome:
I would need information of:

  • Amount contracts active and the cumulative history
  • Current inventory level in units and its' cumulative total over time, which is (inventory purchases - consumption) (this is grouped monthly as consumption always takes place for the whole month even if contract is not valid for a full month). In the end this would be divided by inventory types as well (1 or 2)
  • Total sales amount per month ('consumtion_dim'[consume price] * number of contracts valid each month)
  • Total consumption per month ('consumtion_dim'[consumption per month] * number of contracts valid each month)

Currently I have cumulative contract amount with:
Cumulative contract amount = CALCULATE(
COUNTX(
FILTER('Contract', 'Contract'[start_date] <= MAX( calendar[Date]) && 'Contract'[end_date] > max(calendar[Date])),
'Contract'[Contract_ID]), CROSSFILTER(calendar[Date], 'Contract'[start_date],None))

 

And the cumulative sum of inventory fillings with:

Inventoryfills_CumulativeSum =
    CALCULATE(SUM(inventoryfills_fact[Amount of units]),
        FILTER(ALL(Kalenteri),
            Kalenteri[Date] <= MAX(Kalenteri[Date])
        )
    )

 

But I can't seem to be able to connect inventory levels correctly with the amount of contracts and their unique consumption. 

Open for any ideas you guys might have.

 

Example of Desired outcome:

Year - monthConsumption inventoryinventory typecontract amountcontract revenue
2023 - 0400 00
2023 - 0530220 ( 250 - 30 )1120
2023 - 0630190 ( 160 -30 )1120
2023 - 066040 ( 100- 60 )2118
2023 - 0760 160 1240
2023 - 0760- 202118

 

Cheers! 

 

 

 

1 REPLY 1
lbendlin
Super User
Super User

I would argue that Contracts is a dimension table and consumption is a fact table.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors