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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Super User
Super User

@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.


@ 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!:
The Definitive Guide to Power Query (M)

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors