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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sudeep_92
Regular Visitor

I want to create a DAX to calculate previous 2 years

If I am selecting the current year then it will show last two year data and If not slect any year then it will show only curent and last 2 years data please help thanks in advance

Reason code202120222023
England33%27%11%
China21%46%13%
India55%31%16%
America44%78%17%
2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@sudeep_92 You can build that logic into your measure using similar logic to this: The Complex Selector - Microsoft Fabric Community. Would need to know more about your source data to be more specific.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi thanks for your responce  but your dax is not working for me may be in near future it will help a lot.

I am sharing my current data with you.

 

RGNYearActual DemandActual forecastMape%
APAC202023025087%
NA202023420029%
Europe202045045622%
APAC202065056055%
NA202172060061%
Europe202145650041%
APAC202165776811%
NA202134541377%
Europe202254350029%
APAC202287678922%
NA202254660055%
Europe202229830081%
APAC202312315061%
NA202376575041%
Europe202334540031%
APAC202378690043%

 

In this data I want a DAx that if I select a current year from slicer then it is showing the data with current year and two previous year (i.e. select year is 2023 then data is comming like 2023, 2022 and 2021) and in this table i want to show Mape% year wise with RGN coloum.

 

Thanks in advance if you help me out  🙂

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors