Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

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
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

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.

ibarrau
Super User
Super User

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

sturlaws
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.