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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to retrieve 3 previous years of data with DAX

Hei, is there a way to compact this code for showing 3 years of data?

 

Reservations present year :=
CALCULATE(
              SUM('ssas CustomerDocuments'[Dokumenter]);
                            'ssas CustomerDocuments'[Artikkel]="984 Reservation region1"||
                            'ssas CustomerDocuments'[Artikkel]="985 Reservation region2"||
                            'ssas CustomerDocuments'[Artikkel]="993 Reservation region3"||
                            'ssas CustomerDocuments'[Artikkel]="994 Reservation region4.";
                            DateTable[year]=YEAR(TODAY()))
Reservations last year :=
CALCULATE(
              SUM('ssas CustomerDocuments'[Dokumenter]);
                            'ssas CustomerDocuments'[Artikkel]="984 Reservation region1"||
                            'ssas CustomerDocuments'[Artikkel]="985 Reservation region2"||
                            'ssas CustomerDocuments'[Artikkel]="993 Reservation region3"||
                            'ssas CustomerDocuments'[Artikkel]="994 Reservation region4.";
                            DateTable[year]=YEAR(TODAY())-1)
Reservations two years ago :=
CALCULATE(
              SUM('ssas CustomerDocuments'[Dokumenter]);
                            'ssas CustomerDocuments'[Artikkel]="984 Reservation region1"||
                            'ssas CustomerDocuments'[Artikkel]="985 Reservation region2"||
                            'ssas CustomerDocuments'[Artikkel]="993 Reservation region3"||
                            'ssas CustomerDocuments'[Artikkel]="994 Reservation region4.";
                            DateTable[year]=YEAR(TODAY())-2)
1 ACCEPTED SOLUTION
JosefPrakljacic
Solution Sage
Solution Sage

Hi Dax_New_User

 

I bet you will need the parallelperiod function. 

 

Here are some guides:

https://www.youtube.com/watch?v=yVZHbKKIzDE

https://docs.microsoft.com/en-us/dax/parallelperiod-function-dax

 

If you need further help please share some example data.

 

If this post was helpful may I ask you to mark it as a solution and share some kudos 🙂

 

Have a nice day!

 

BR,

Josef

View solution in original post

1 REPLY 1
JosefPrakljacic
Solution Sage
Solution Sage

Hi Dax_New_User

 

I bet you will need the parallelperiod function. 

 

Here are some guides:

https://www.youtube.com/watch?v=yVZHbKKIzDE

https://docs.microsoft.com/en-us/dax/parallelperiod-function-dax

 

If you need further help please share some example data.

 

If this post was helpful may I ask you to mark it as a solution and share some kudos 🙂

 

Have a nice day!

 

BR,

Josef

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.