Forum Discussion
Calculate On Hand quantity
- 9 years ago
Hi afaque03,
My mistake.
Could you try the formula below to see if it works? :smileyhappy:
On-Hand Quantity = VAR currentYearMonth = MAX ( 'Table1'[YearMonth] ) VAR productName = FIRSTNONBLANK ( 'Table1'[Product Name], 1 ) RETURN CALCULATE ( SUM ( 'Table1'[Incoming Quantity] ) - SUM ( 'Table1'[Outgoing Quantity] ), FILTER ( ALL ( Table1 ), 'Table1'[YearMonth] <= currentYearMonth - 1 && 'Table1'[Product Name] = productName ) )Regards
Hi afaque03,
My mistake.
Could you try the formula below to see if it works? :smileyhappy:
On-Hand Quantity =
VAR currentYearMonth =
MAX ( 'Table1'[YearMonth] )
VAR productName =
FIRSTNONBLANK ( 'Table1'[Product Name], 1 )
RETURN
CALCULATE (
SUM ( 'Table1'[Incoming Quantity] ) - SUM ( 'Table1'[Outgoing Quantity] ),
FILTER (
ALL ( Table1 ),
'Table1'[YearMonth]
<= currentYearMonth - 1
&& 'Table1'[Product Name] = productName
)
)
Regards
v-ljerr-msftSorry to bother you again. Can you help me to make the change in the DAX in case when there is no incoming and outgoing then On-Hand quantity of that month should get carry forwarded to onhand quantity of next month. Currently the DAX does not carry forward the On-Hand quantity.
"On-Hand Quantity = VAR currentYearMonth = MAX (Inventory[YearMonth] ) VAR productName = FIRSTNONBLANK ( Inventory[Product Name], 1 ) RETURN CALCULATE ( SUM ( Inventory[Incoming Quantity] ) - SUM ( Inventory[Outgoing Quantity] ), FILTER ( ALL ( Inventory ), Inventory[YearMonth] <= currentYearMonth - 1 && Inventory[Product Name] = productName ) ) ". Attached is the snapshot of that report in which for the month of may the On-Hand quantity is 684 and when there is no incoming and outgoing quantity for june the On-Hand quantity also becomes blank.