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
vipin_jha123
Frequent Visitor

Get Total sales amont of last 5 years

Hi ,

I have sales table , in in that table I have data of last 5 years.

Now My requirment is to get the total sales amount of last 5 years like  2016,2015,2014,2013,2012

similarly Can I also get the total sales amonut of last 5 years same month

for example if current month is aug 2017 , so I can se thae 1ug 2016,aug 2015 and so on

 

Thanks in advance

Vipin Jha

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @vipin_jha123,

 

 You can create a calendar table, then create a measure like below:

 

Measure = CALCULATE(SUM(Table1[Value]),FILTER('Table1',MONTH('Table1'[Date])=MONTH(MAX('Calendar'[Date])) && YEAR('Table1'[Date])>=YEAR(MAX('Calendar'[Date]))-5 && YEAR('Table1'[Date])<=YEAR(MAX('Calendar'[Date]))))

 

I create a report use dummy data(1/1/2016 - 12/31/2017) to calculate the total value for the same month for last year and current year for your reference, for detail information, you can see attached pbix file.

q1.PNGq2.PNG

 

Best Regards,
QiuyunYu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-qiuyu-msft
Community Support
Community Support

Hi @vipin_jha123,

 

 You can create a calendar table, then create a measure like below:

 

Measure = CALCULATE(SUM(Table1[Value]),FILTER('Table1',MONTH('Table1'[Date])=MONTH(MAX('Calendar'[Date])) && YEAR('Table1'[Date])>=YEAR(MAX('Calendar'[Date]))-5 && YEAR('Table1'[Date])<=YEAR(MAX('Calendar'[Date]))))

 

I create a report use dummy data(1/1/2016 - 12/31/2017) to calculate the total value for the same month for last year and current year for your reference, for detail information, you can see attached pbix file.

q1.PNGq2.PNG

 

Best Regards,
QiuyunYu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This could be complex to achieve using the standar Time Intelligence functions in DAX, unless you use UNION and you append multiple results provided by DATEADD.

CALCULATE (
     [measure],
     UNION (
         UNION (
            VALUES ( 'Date'[Date] ),
            DATEADD ( 'Date'[Date], -1, YEAR )
        ),
        UNION ( 
            UNION ( 
                DATEADD ( 'Date'[Date], -2, YEAR ),
                DATEADD ( 'Date'[Date], -3, YEAR )
            ),
            DATEADD ( 'Date'[Date], -4, YEAR )
       )
    )
)
       

Another approach is using a custom time inlelligence such as the Time Patterns: http://www.daxpatterns.com/time-patterns/

 

Marco Russo - SQLBI

 

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.