cancel
Showing results for
Did you mean:
Regular Visitor

## LY Quarter Sales year and quarter only

Hello friends,

I have a table with year and quarter information only. I would like to have LY quarter sales for example, but since I don't have dates the inbuilt functions like SAMEPERIODLASTYEAR are not applicable.

The expected result is:

 Year Quarter Total Sales LY Quarter Sales Var 2017 Q2 862 2017 Q3 797 2017 Q4 825 2018 Q1 839 2018 Q2 895 862 33 2018 Q3 809 797 12 2018 Q4 814 825 -11 2019 Q1 877 839 38

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support

## Re: LY Quarter Sales year and quarter only

Hi @BorisEV ,

You can create measures like DAX below.

LY Quarter Sales = CALCULATE(MAX('Table'[Total Sales]),FILTER(ALLSELECTED('Table'),'Table'[Quarter]=MAX('Table'[Quarter])&&'Table'[Year]=MAX('Table'[Year])-1))

Var = IF(ISBLANK([LY Quarter Sales]),BLANK(),MAX('Table'[Total Sales])-[LY Quarter Sales])

Best Regards,

Amy

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

3 REPLIES 3
Super User III

## Re: LY Quarter Sales year and quarter only

Hi @BorisEV

have you tried creating a column with the first date of each quater? E.g. Q1-2017 becomes 2017-01-01 and Q3-2017 becomes 2017-07-01. You can use various date-function on such a column.

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Super User II

## Re: LY Quarter Sales year and quarter only

Hi, you can force a date like the first month and day of the quarter for each year. For example think on Q1 as january, Q2 as april, etc. Create your date column with that thinking to model. Then you can use Time Intelligence with a date table to enable sameperiodlastyear. Another approach is creating a measure that will depend on how you are going to use it.

For example, if you are adding year and quarter in the visualization like the table you have there, you can write this measure:

``````LY =
VAR maxi = MAX (Tabla[Year]) -1
RETURN
CALCULATE(
SUM ( Tabla[Value] )
; Tabla[Year] = maxi
)``````

With this you will probably be able to have your result, but again, it will depend on the visualization (filter and row context)

Regards,

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

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

Happy to help!

Community Support

## Re: LY Quarter Sales year and quarter only

Hi @BorisEV ,

You can create measures like DAX below.

LY Quarter Sales = CALCULATE(MAX('Table'[Total Sales]),FILTER(ALLSELECTED('Table'),'Table'[Quarter]=MAX('Table'[Quarter])&&'Table'[Year]=MAX('Table'[Year])-1))

Var = IF(ISBLANK([LY Quarter Sales]),BLANK(),MAX('Table'[Total Sales])-[LY Quarter Sales])

Best Regards,

Amy

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

Announcements

#### New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

#### ‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

#### Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors
Top Kudoed Authors