Forum Discussion

shanipowerbi's avatar
shanipowerbi
Icon for Helper III rankHelper III
6 years ago
Solved

Second Last Invoice Amount

Hi Experts   I need your help to calculate second last invoice amount. I have two table that contain 1 - Invoive Data Invoice ID / User ID / Invoice Amount / Invoice Date   2 - User Profiling D...
  • VasTg's avatar
    VasTg
    6 years ago

    shanipowerbi 

     

    I believe you are trying to create a column.

     

    This should work.

     

    2ND Last Invoice Amount =
    VAR LAST_DATE =
        LASTDATE ( Invoice[Invoice Date] )
    VAR PREVIOUS_DATE =
        CALCULATE (
            MAX ( Invoice[Invoice Date] ),
            FILTER ( ALL ( Invoice[Invoice Date] ), Invoice[Invoice Date] < LAST_DATE )
        )
    RETURN
        CALCULATE (
            SUM ( Invoice[Invoice Amt] ),
            Invoice[Invoice Date] = PREVIOUS_DATE
        )

     

    If it helps mark it as a solution.

    Kudos are nice too