cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BorisEV
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:

YearQuarterTotal SalesLY Quarter SalesVar
2017Q2862  
2017Q3797  
2017Q4825  
2018Q1839  
2018Q289586233
2018Q380979712
2018Q4814825-11
2019Q187783938

 

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
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.

View solution in original post

3 REPLIES 3
Super User III
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
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!

LaDataWeb Blog


Community Support
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.

View solution in original post

Helpful resources

Announcements
New Ranks Launched March 24th!

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!

‘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

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