Forum Discussion

vijay273162's avatar
vijay273162
Icon for Helper III rankHelper III
4 years ago
Solved

SAME PERIOD LAST YEAR

Hi All,   basic Question from my side.  HOW TO USE SAME PERIOD LAST YEAR  ---- in ----- calculated columns ?  
  • v-xiaotang's avatar
    4 years ago

    Hi vijay273162 

    If you are using dates from a fact table, try this way,

    column = 
    VAR _date =
        EDATE ( 'Table'[Date], -12 )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Date] >= _date
                    && 'Table'[Date] < EARLIER ( 'Table'[Date] )
            )
        )

    If you want to create measure, then try this

    LY = CALCULATE(SUM('Table'[Sales]),SAMEPERIODLASTYEAR('Table'[Date]))

    Best Regards,

    Community Support Team _Tang

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