Forum Discussion
Inventory changes using DAX - intra-location opening and closing dilemma
I also need to solve a similar problem, also for ore block to stockpile to crusher movements for an open pit operation... with an identical table.
Just wondering if you managed to solve this one, and if you could kindly share some details!
Many thanks,
Tim
- mwimberger7 years ago
Resolver II
Hi Tim
I did manage to solve this. My initial solution was to use USERELATIONSHIP, but this wasn't completely without issue as it seemed to slow things down.
What I then settled on was a second referenced query ( subset of the the initial data) and a relationship of this query to the Distinct list of locations ( in and outs)
I will detail exactly how I did this with a longer post soon. Good to see some mining related interest out there!Cheers
Manfred
- roset037 years agoFrequent Visitor
Appreciate the update Manfred! Would be great if you could update us in due course. Hopefully we can compare notes, and work a really nice solution.
I assume your end goal is similar to mine - for blend planning for crusher feed grade?
Many thanks!
Tim
- mwimberger7 years ago
Resolver II
Hi roset03
The end goal is partly for blending, but by far the biggest goal was to complete a complete value chain reconciliation framework linking Geology, Mining and Metallurgy. As you would know, stockpiles are generally a handover point between departments, and thus can prove to be the most difficult to manage. And for most reconciliation studies, the Delta in the stockpiles are what are needed to account for material that does not go directly from the Pit to the Plant.
My solution was to do the following:
Create a separate table data (filtered) of intrastockpile movements from the Data table
Data Filtered IntraStockpile = FILTER ( Data, LEFT ( Data[Unified_Origen], 6 ) = "Stock " && LEFT ( Data[Unified_Destination], 6 ) = "Stock "Note above I created a "unified" identifier as the dispatch system for some reason has differing orders of taxonomy in naming sources and destinations.
Then I created a dimension table which generated a list of the stockpile ID and stockpile ID Detail ( I needed Stockpiles grouped into Oxide, Sulphide or Mixed)
tblStockpileIDUnique = FILTER ( SUMMARIZE ( data, Data[Stockpile_ID], Data[Stockpile_ID_Detail] ), Data[Stockpile_ID_Detail] <> "" )This dimension table was linked to the original data table and the filtered table - but it uses the following relationships:
data[Source] *---->tblStockpileIDUnique[Stockpile_ID_Detail] <----* Data Filtered IntraStockpile[Destination]
Tonnage In is calculated as
Tonnage In = CALCULATE ( SUM ( 'Data Filtered IntraStockpile'[TON_AJUSTADO] ), 'Data Filtered IntraStockpile'[In_Code] = "OUT" ) + CALCULATE ( SUM ( 'Data'[TON_AJUSTADO] ), 'Data'[In_Code] = "IN" )Tonnage out calculated as
Tonnage Out = calculate(sum('Data'[TON_AJUSTADO]),'Data'[In_Code]="OUT")Tonnage movement calced as:
Tonnage Movement = [Tonnage In]-[Tonnage Out]
And then openings and closings defined as :
Opening Stock Tonnes = VAR vLastDate = min('Data'[FECHA]) Return CALCULATE ( [Tonnage Movement], FILTER ( ALLEXCEPT ( Data, Data[Stockpile_ID],Data[Stockpile_ID_Detail] ) ,'Data'[FECHA] < vLastDate ) ) Closing Stock Tonnes = CALCULATE ( [Tonnage Movement], FILTER ( ALLEXCEPT ( Data, Data[Stockpile_ID], Data[Stockpile_ID_Detail] ), 'Data'[FECHA] <= MAX ( 'Data'[FECHA] ) )(note Fecha means date in Spanish)
So basically the solve is to link the stockpiles to both the Source and Destination (using the two seperate tables) and use the the IN or OUT code to calculate additions and subtractions from the material movement. There is a bit more to the setups that precede these steps, such as defining whether the material is moving IN or OUT ( as per the diagram above) but that is fairly easy.
IM me on LinkedIn if you need futher information - happy to discuss if you need any further assistance assistance.Cheers
Manfred