Forum Discussion

Jorn_Mazet's avatar
Jorn_Mazet
Regular Visitor
2 years ago

Correct Batch used?

Hi all,

PBIX with sample data through this link (pbix in Google Drive)

I have a fact table with transactions, showing at what date a batch is used:

I also have a table with all articles, batches for these articles, with ExpiryDate, OpeningDate (batch start) and ClosingDate (batch items used up).
A batch is unique in that sence that the batch ID will be used only once.

Goal of my report is to analyse if the used batch in the transaction is the ideal one (sometimes wrong batches get used).

The ideal batch needs to follow these rules:
1) the opening date needs to be before the transaction date and the closing date needs to be after the transaction date (if not, the batch isn't in use at that specific time)

2) if multiple batches are available within rule 1, the batch that expires the fastest is the ideal one to use.

3) we can only use batches that have not expired in our transaction

I'm looking for a measure that will tell me what the ideal batch would have been, so I can compare with the used batch (in the transaction) and detect non-ideal usage.


I really don't know where to start to do this...
All help appreciated!



 

5 Replies

    • Jorn_Mazet's avatar
      Jorn_Mazet
      Regular Visitor

      Hey lbendlin,

      Thanks for taking the time to help me get started on the logic of doing this!! Much appreciated!
      Just trying to understand why article 0002 and 0003 don't get a Best Batch result, as var ar makes sure that the correct article is selected...

      • lbendlin's avatar
        lbendlin
        Super User

        Transaction Date is past Expiration Date, violating rule 3.