Forum Discussion

SvenvandenHil's avatar
SvenvandenHil
Frequent Visitor
2 years ago
Solved

Inventory list value from prices

Hi, We have an inventory list and for each item you can see how much the inventory changes per date and location. I already made a PBI for the quantity of each item on specific dates, but next to...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, SvenvandenHil 

    Regarding the issue you raised, my solution is as follows:

    1.First, I created a time calculation table as a slicer:

    Time = 
    CALENDAR (
        MIN (
            MIN ( 'InventItemPriceStaging'[ACTIVATIONDATE] ),
            MIN ( 'MainInventoryTransactions'[Inventory Physical Date] )
        ),
        MAX (
            MAX ( 'MainInventoryTransactions'[Inventory Physical Date] ),
            MAX ( 'MainInventoryTransactions'[Inventory Physical Date] )
        )
    )

    2. Below are the measure I've created for your needs:

    MEASURE = 
    VAR select1 =
        MAX ( 'Time'[Date] )
    VAR type1 =
        CALCULATE (
            MAX ( 'InventItemPriceStaging'[PRICETYPE] ),
            FILTER (
                ALLEXCEPT (
                    'InventItemPriceStaging',
                    'InventItemPriceStaging'[ITEMID],
                    'InventItemPriceStaging'[LOCATION]
                ),
                'InventItemPriceStaging'[ACTIVATIONDATE] <= select1
            )
        )
    VAR unit1 =
        CALCULATE (
            MAX ( 'InventItemPriceStaging'[PRICEUNIT] ),
            ALLEXCEPT (
                InventItemPriceStaging,
                'InventItemPriceStaging'[ITEMID],
                'InventItemPriceStaging'[LOCATION]
            )
        )
    VAR price1 =
        CALCULATE (
            MAX ( 'InventItemPriceStaging'[PRICE] ),
            FILTER (
                ALLEXCEPT (
                    'InventItemPriceStaging',
                    'InventItemPriceStaging'[ITEMID],
                    'InventItemPriceStaging'[LOCATION]
                ),
                'InventItemPriceStaging'[ACTIVATIONDATE] <= select1
                    && 'InventItemPriceStaging'[PRICETYPE] = type1
            )
        )
    VAR price2 = price1 / unit1
    VAR cid =
        MAX ( 'InventItemPriceStaging'[ITEMID] )
    VAR cl =
        MAX ( 'InventItemPriceStaging'[LOCATION] )
    VAR inventor =
        CALCULATE (
            SUM ( MainInventoryTransactions[Quantity Inventory Unit] ),
            FILTER (
                'MainInventoryTransactions',
                'MainInventoryTransactions'[Inventory Physical Date] <= select1
                    && 'MainInventoryTransactions'[ITEMID] = cid
                    && 'MainInventoryTransactions'[LOCATION] = cl
            )
        )
    RETURN
        inventor * price2

    3.Here's my final result, which I hope meets your requirements.

     

     

     

     

     

     

     

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.