Forum Discussion

rajibmahmud's avatar
rajibmahmud
Helper III
9 years ago
Solved

Time intelligence Last 3 year

Using DAX time intelligence function we could compar Current year data vs last year data or Last year same period data.

 

Is there any option to do it for last 3-4 year data?

 

What I am looking for is based on Current year selection BI will provide me not only LY but also -2 and -3 year values.

 

Result could be like below table.

 

 CYSameperiod LY2 Years back3 Years back
Margin100908050

 

Sample Data

 

YearCurrency
2017100
201690
201580
201450
  • TomMartens's avatar
    TomMartens
    9 years ago

    Hey,

     

    there was just a little issue ;-) Here you find your slightly modified pbix file

     

    Your Formula

    PY = CALCULATE(sum('Sales'[Value]), SAMEPERIODLASTYEAR('Sales'[FDate]))

    Working Formula

    PY Working = 
    CALCULATE(
    	sum('Sales'[Value]), 
    	SAMEPERIODLASTYEAR('Calendardb'[Date])
    	)

    The difference:

    It always (ok - in most cases) to filter the fact table (Sales) using dimension tables (CalendarDB). For this reason the function SAMEPERIODLASTYEAR has to reference the dimensiontable. SAMEPERIODLASTYEAR() expands the current filter of the CalendarDB table, and these rows are propagated to sales table using the relationship (CalendarDB --> Sales)

     

    Voila :-)

     

    Have a nice weekend

15 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Total Value:=SUM(Table2[Value])

    YTD:=calculate([Total Value], DATESYTD(Dates[Date]))

    1YP:=CALCULATE([Total Value], DATEADD(DATESYTD(Dates[Date]), -1, YEAR))

    2YP:=CALCULATE([Total Value], DATEADD(DATESYTD(Dates[Date]), -2, YEAR))

     

    • rajibmahmud's avatar
      rajibmahmud
      Helper III

      Anonymous Thanks alot.

       

      Another noob query I have, If my table have Year and Month in seperate column. Month in Jan, Feb, Mar - This format (First 3 letter).

       

      Can I use time intelligence formula on this scenario?

       

      Sample data

       

      YearMonthCurrency
      2017Jan100
      2017Feb200
      2017Mar300
      2016Jan100
      2016Feb200
      2016Mar300