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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Wadda7AboUdai
Helper I
Helper I

calculate selected year stock and last year

Hello Everyone 

 

I have  this measure to get the stock for the selected year in filter 

Selected Year = CALCULATE(SUM(GENERALJOURNALS[AMOUNT]),FILTER(GENERALJOURNALS,GENERALJOURNALS[MAINACCOUNT] = 5637144608))

 
Now I want to create  measure shows the stock  for last year of selected year, for example 
If the selected year was 2022 the colum3 should calculate data for 2021 , If the selected year was 2021 the column 3 
should calculate data for 2020 and so on , I hope I could explain what I need 
Wadda7AboUdai_0-1667226635409.png

 

 
 

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Wadda7AboUdai ,

 

Create a calendar table and relate it to your fact table on Calendar[Date] ONE : MANY Fact[Date], then use the following measure:

_PriorYear =
CALCULATE(
    [Selected Year],
    SAMEPERIODLASTYEAR(Calendar[Date])
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @Wadda7AboUdai ,

 

Create a calendar table and relate it to your fact table on Calendar[Date] ONE : MANY Fact[Date], then use the following measure:

_PriorYear =
CALCULATE(
    [Selected Year],
    SAMEPERIODLASTYEAR(Calendar[Date])
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.