Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Finding total value from previous month

I need to find the delta between total qty of current month to the total qty of the previous month.

So, I create PrevDate column to show previous month

I need to report the total quantity of the previous month

 

 

 

I use below formula but didn't get the result.

 

Please help 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    I suggest you to try code as below.

    PrevQty =
    VAR _item =
        MAX ( Inven[Item Number] )
    VAR _date1 =
        MAX ( Inven[PevDate] )
    VAR _date2 =
        MAX ( Inven[RT_YY_MM] )
    VAR _result =
        IF (
            _date1 = BLANK (),
            0,
            CALCULATE (
                SUM ( Inven[Quantity] ),
                FILTER (
                    ALLSELECTED ( Inven ),
                    Inven[Item Number] = _item
                        && Inven[RT_YY_MM] = _date2
                        && Inven[FileDate]
                            = EOMONTH ( _date1, 0 ) + 1
                )
            )
        )
    RETURN
        _result

    If this reply still couldn't help you resolve your issue, please share a sample file with me.

     

    Best Regards,
    Rico Zhou

     

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

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    I suggest you to try code as below.

    PrevQty =
    VAR _item =
        MAX ( Inven[Item Number] )
    VAR _date1 =
        MAX ( Inven[PevDate] )
    VAR _date2 =
        MAX ( Inven[RT_YY_MM] )
    VAR _result =
        IF (
            _date1 = BLANK (),
            0,
            CALCULATE (
                SUM ( Inven[Quantity] ),
                FILTER (
                    ALLSELECTED ( Inven ),
                    Inven[Item Number] = _item
                        && Inven[RT_YY_MM] = _date2
                        && Inven[FileDate]
                            = EOMONTH ( _date1, 0 ) + 1
                )
            )
        )
    RETURN
        _result

    If this reply still couldn't help you resolve your issue, please share a sample file with me.

     

    Best Regards,
    Rico Zhou

     

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