Forum Discussion
Inventory list value from prices
- Anonymous2 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 * price23.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.
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.
Hi Leroy Lu,
Measure works great. On a few items I don't get the reponse as expected, but that's due to something in the dataset. Thank you for your help.