Forum Discussion
Naxyr
6 years agoNew Member
Need help Getting LOT Numbers based of LIFO
I Have got 2 Tables 1 Is having Stock In hand Code SIH ( Qty) 2 is having batch Wise Goods Receipts Code Date Received Qty Lot Number Exp Date Want to allocate Balance SIH (L...
- 5 years ago
Hi Naxyr ,
Please check:
Measure = VAR RunningTotal = CALCULATE ( SUM ( 'Table 2'[QTY] ), FILTER ( ALLSELECTED ( 'Table 2' ), 'Table 2'[CODE] = MAX ( 'Table 2'[CODE] ) && 'Table 2'[Expiration Date] >= MAX ( 'Table 2'[Expiration Date] ) ) ) VAR RunningTotal_ = CALCULATE ( SUM ( 'Table 2'[QTY] ), FILTER ( ALLSELECTED ( 'Table 2' ), 'Table 2'[CODE] = MAX ( 'Table 2'[CODE] ) && 'Table 2'[Expiration Date] > MAX ( 'Table 2'[Expiration Date] ) ) ) VAR SIH_ = SUM ( 'Table 1'[SIH] ) RETURN IF ( HASONEVALUE ( 'Table 2'[Expiration Date] ), MAX ( IF ( RunningTotal <= SIH_, SUM ( 'Table 2'[QTY] ), SIH_ - RunningTotal_ ), BLANK () ), SUM ( 'Table 1'[SIH] ) )Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Icey
Community Support
5 years agoHi Naxyr ,
Please check:
Measure =
VAR RunningTotal =
CALCULATE (
SUM ( 'Table 2'[QTY] ),
FILTER (
ALLSELECTED ( 'Table 2' ),
'Table 2'[CODE] = MAX ( 'Table 2'[CODE] )
&& 'Table 2'[Expiration Date] >= MAX ( 'Table 2'[Expiration Date] )
)
)
VAR RunningTotal_ =
CALCULATE (
SUM ( 'Table 2'[QTY] ),
FILTER (
ALLSELECTED ( 'Table 2' ),
'Table 2'[CODE] = MAX ( 'Table 2'[CODE] )
&& 'Table 2'[Expiration Date] > MAX ( 'Table 2'[Expiration Date] )
)
)
VAR SIH_ =
SUM ( 'Table 1'[SIH] )
RETURN
IF (
HASONEVALUE ( 'Table 2'[Expiration Date] ),
MAX (
IF ( RunningTotal <= SIH_, SUM ( 'Table 2'[QTY] ), SIH_ - RunningTotal_ ),
BLANK ()
),
SUM ( 'Table 1'[SIH] )
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- yavuzonaran3 years agoFrequent Visitor
This works thanks a lot!
I wonder if its possible to calculate in data table?
I also would like to calculate weighted average # of days by multiplying today-prod. date and qty.
Thanks in advance