Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Add new column with filters based on current row values

My main question here is around how to filter based on a value taken from the current column.   In this case I have a column Dates.Month (which is a whole number in the format YYYYMM) and a new cal...
  • Icey's avatar
    6 years ago

    Hi Anonymous ,

     

    Try this:

    Column =
    VAR LastMonth = 'Table'[Dates.BeforeMonth]
    RETURN
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Dates.Month] = LastMonth )
        )
    

    or,

    Column =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Dates.Month] = EARLIER ( 'Table'[Dates.BeforeMonth] )
        )
    )
    
    

     

     

    Best Regards,

    Icey

     

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