Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Very simple calculation question

I have one Table with 3 columns in PowerBI. I am trying to make a calculated column - "PrevNumber"   PrevUniqueID will always have a match in the UniqueID column of a different Row. Goal is to...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    Try this code to create a calculated column.

    PreviousMonthNumber =
    VAR _PreMonthUniqueID =
        CALCULATE (
            SUM ( 'Table'[Number] ),
            FILTER ( 'Table', 'Table'[UniqueID] = EARLIER ( 'Table'[PreMonthUniqueID] ) )
        )
    RETURN
        _PreMonthUniqueID + 0

    Result is as below.

     

    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.