Hi Matt!
I'm really sorry but that's not the point as the problem is that the last number doesn't always correspond to the SoH.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]IdProduct[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134"]DateTime[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]Number[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]Stock[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]M4290282[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134, align: right"]30/01/2019 9:00:23[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]7806165[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]10.810[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]M4290282[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134, align: right"]30/01/2019 9:01:08[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]7806282[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]10.804[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]M4290282[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134, align: right"]30/01/2019 11:15:45[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]
7805376[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]10.798[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]M3015495[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134, align: right"]30/01/2019 9:07:38[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]7807378[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]184.906[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]M3015495[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134, align: right"]30/01/2019 9:07:43[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]7807397[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]183.982[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]M3015495[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134, align: right"]30/01/2019 15:58:37[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]7827286[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]177.249[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]M3015495[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134, align: right"]31/01/2019 17:51:50[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]
7807753[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]177.249[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80"]M3015495[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 134"]
<tbody>[TR="class: grid"]
[TD="width: 134, align: right"]31/01/2019 17:51:50[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]
7807752[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 80"]
<tbody>[TR="class: grid"]
[TD="width: 80, align: right"]170.495[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
I've copied part of the table...
As you can see in the first product (M4290282), the SoH correspond to the last date-time, but doesn't correspond to the last number, as the last datetime only has one movement.
In the second product (M3015495), the last datetime has two movements, in this case, as there are two movements with the same datetime, the last movement is the correct stock.
Thank you!!!!
Baye
It is nothing to do with Excel. I can't open your Excel workbook (it says it is corrupt), but I could copy it to Power BI. This is what you need to do.
1. split the date and time into 2 separate columns.
2. Load a calendar table
https://exceleratorbi.com.au/power-pivot-calendar-tables/
3. Join the tables on data, and put the Date from Calendar in a visual
4. From what I can see, the MvtID keeps incrementing, so i don't think you need the time stamp.
This measure should give you the last stock on hand
Code:
SOH =SUMX (
VALUES ( Stock[IdProduct] ),
CALCULATE (
SUM ( Stock[Stock] ),
FILTER ( ALL ( Stock[Number] ), Stock[Number] = MAX ( Stock[Number] ) )
)
)