Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago

Need help with Same Period Last Year

Hi All

 

I have worked out a measure to sum a column of sales for the same period in a prior year, in my case this is the same quarter last year and a calculation of sales in the prior quarter. This works fine.

 

But as I have rows of sales in the same period in the prior year, I would like to flag those rows of revenue as opposed to creating a measure to summarise them.

 

I want to show this flag on my table called "sales", this row was in the same date period of the prior year.

 

Any ideas? I know I need a calculated column as opposed to a measure. I have a linked date table to work out dates called "DateKey".

 

Thanks

1 Reply

  • v-cherch-msft's avatar
    v-cherch-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Anonymous

     

    You may try to use EARLIER Function in calculated column. If it is not your case, please share some data sample and expected output. For example:

     

    PeriodLastYear =
    CALCULATE (
        SUM ( Sales[Sales] ),
        FILTER (
            Sales,
            YEAR ( Sales[Date] )
                = YEAR ( EARLIER ( Sales[Date] ) ) - 1
                && MONTH ( Sales[Date] ) = MONTH ( EARLIER ( Sales[Date] ) )
                && DAY ( Sales[Date] ) = DAY ( EARLIER ( Sales[Date] ) )
        )
    )

    Regards,

    Cherie