Forum Discussion
Calculating previous year sales (Not including current year)
Need to find previous year sales and need the calculation for the same.
This shouldnt include the current year and only show values from the previous year. Example i have data till june 2023 , i would need to find the value from jan 2022 to dec 2022. (Pevious entire year) and exclude the current year values.
6 Replies
- Ritaf1983
Super User
Hi UditJ
You can use the parallel period dax function.
Please see the linked discussion:
https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-achieve-a-full-year-last-year-measure/m-p/2471652If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
- UditJ
Helper III
Parralle period function is giving me all the values of previous years - 2021 and 2022. I need just 2022.
- Ahmedx
Super User
pls try this
Measure = VAR FirstDateOfCorrentYear = DATE(YEAR(TODAY()),1,1) VAR _EndDateOfLastYear = FirstDateOfCorrentYear -1 VAR _FirstDateOfLastYear = DATE(YEAR(_EndDateOfLastYear),1,1) RETURN CALCULATE( SUM(table[Sales]),KEEPFILTERS( DATESBETWEEN('Calendar'[Date],_FirstDateOfLastYear,_EndDateOfLastYear)))- UditJ
Helper III
In the below line i need to call a claucalted measure instead of sum(table[sales] ). Calucalted measure is - Divide (sales , profit)
CALCULATE( SUM(table[Sales]),KEEPFILTERS( DATESBETWEEN('Calendar'[Date],_FirstDateOfLastYear,_EndDateOfLastYear)))any suggestions ?
- Ahmedx
Super User
create two measures
first for saleАmo = VAR FirstDateOfCorrentYear = DATE(YEAR(TODAY()),1,1) VAR _EndDateOfLastYear = FirstDateOfCorrentYear -1 VAR _FirstDateOfLastYear = DATE(YEAR(_EndDateOfLastYear),1,1) RETURN CALCULATE( SUM(table[Sales]),KEEPFILTERS( DATESBETWEEN('Calendar'[Date],_FirstDateOfLastYear,_EndDateOfLastYear)))
the second one is for profitprofit = VAR FirstDateOfCorrentYear = DATE(YEAR(TODAY()),1,1) VAR _EndDateOfLastYear = FirstDateOfCorrentYear -1 VAR _FirstDateOfLastYear = DATE(YEAR(_EndDateOfLastYear),1,1) RETURN CALCULATE( SUM(table[profit]),KEEPFILTERS( DATESBETWEEN('Calendar'[Date],_FirstDateOfLastYear,_EndDateOfLastYear)))third
= DIVIDE([Sales],[profit])