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.
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 |
Thank you in advance
Solved! Go to Solution.
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.
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.
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.
Happy to help!
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
99 | |
76 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |