Many thanks for looking into this. I have just tried to translate your code into my original model, but it is not working properly. Most likely I’m doing something wrong, but I can’t figure out what.
I have now attached a dummy copy of the original report I’m working on, hopefull this will help in making my issue more clear.
for each day, I want to calculate the value of the stock. This is based on the Stockmovement History table. It should be QTY * Costs. But as you can see, the Costs column is not always filled in, as we only start doing this from 15-04-2020. So we want the period from 01-01-2020 te be calculated by the costs on 15-04-2020.
If the date filter is based on complete period from the database, the measure for “pricedate” and “costs on pricedate” seem to be okay. but if i change this date filter to only this month, it is changing the pricedate and costs to the first date in the selected period. But it should always be the values for 15-04 as that was the first day the cost field was filled in the database.
The measure 'Inkoopwaarde voorraad" was made by me, but this is based on the current product value and they may change over time, so this is not correct. The measure “Inkoopwaarde voorraad obv cost” should look at the cost field from Stockmovement history and this is working correctly from 15-04 onwards, but this needs to be filled for the period befor 15-04.
I hope you will be able to have another look at this and help me out with it