Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Dear community:
I calculate the unit price using power bi sameperiodlastyear() , I have a small database it contains only sales of 2022 till today which is feb 2024. and I want to know yoy% , the returned calculation is not correct, I found out the reason is, sameperiodlastyear() take 2022 and 2023 two years sale data to calculate unit price instead of using only 2023 year's data , why?
this is my code for yoy% in calculation group
this is my YoY% measure using calculation group:DIVIDE( CALCULATE( SELECTEDMEASURE(), FILTER( DateTable, INT( 'DateTable'[Year] ) = YEAR( MAX('T sales'[invoice date]) ) ) ), CALCULATE( SELECTEDMEASURE( ), SAMEPERIODLASTYEAR(DateTable[date]) ) )-1
when i using this measure, it compares the unit price of 2024 with 2022 and 2023 data together, ( this means it uses total sales of 2022+2023 divide total quantity of 2022+2023, which is incorrect.
I think I don't understand the behaviour of sameperiodelastyear() quite well.
Hi @Laughter ,
According to your statement, I think your issue may be that your measure in calculation group will return the data in two years instead of one year.
As far as I know, the result it result is based on the measure you use in SELECTEDMEASURE().
So we need more information about your measure.
Please share a sample file with us and show us a screenshot.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Laughter ,
You need to reference a measure with the first period
VAR Period1 =
CALCULATE(
SELECTEDMEASURE(),
FILTER( DateTable, year( 'DateTable'[date] ) = YEAR( MAX('T sales'[invoice date]) ) )
)
VAR Period2 =
CALCULATE(
Period1,
SAMEPERIODLASTYEAR(DateTable[date])
)
RETURN
DIVIDE( Period1, Period2) -1
You can write periodd2 as this, if you prefer
VAR Period2 =
CALCULATE(
Period1,
dateadd(DateTable[date],-1,year)
)
You can find usefull information here: Differences between DATEADD and PARALLELPERIOD in DAX - SQLBI
@Laughter You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000
Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...
Also:
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.