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
Reuben
Helper III
Helper III

YTD vs LYTD vs Full Year n-1 vs Full Year n-2

 

Hello,

 

I am trying to compare YTD (1) production at the selected Financial Year and Financial month filtered with a the following slicer

(Slicer Year = FY19 / Slicer Month = March) with last year in the same month LYTD (2).

(1) YTD  Production = calculate([Production];datesytd('Calendar'[Date];"30/06") -

(2) LYTD = calculate([YTD Production];SAMEPERIODLASTYEAR('Calendar'[Date]))

Then I want to compare also with last full year (FY18, from 01/07/17 to 30/06/18) and FY17 (from 01/07/16 to 30/06/17). How could I do this?

 

Thank you very much for your help

Reubben

2 ACCEPTED SOLUTIONS

You could write a custom time intelligence functions to do this

Sales Current Year =
VAR CurrentYear =
    MAX ( calendar[year] )
RETURN
    CALCULATE (
        [Total Sales],
        FILTER ( ALL ( calendar ), calendar[Year] = CurrentYear )
    )

and this

Sales Last Year =
VAR CurrentYear =
    MAX ( calendar[year] )
VAR LastYear = CurrentYear - 1
RETURN
    CALCULATE (
        [Total Sales],
        FILTER ( ALL ( calendar ), calendar[Year] = LastYear)
    )

You can read my article about time intelligence in Power BI here 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

Hi @MattAllington 

Thank you very much for answering. Following your tip I have applied your measure to my model and it gives me a wrong result as I am working with fiscal year ( from 1s july to 30th june). Following the logical, if I change Calendar[Year] for Calendar[FiscalYear], the result is an error. May be is because Calendar[FiscalYear] in the calendar table is difined as FY16, FY17... FY20, but I don´t know how to solve it.

 

By the way, I have take a look to your article and I find it very interesting. Its very helpfull for  newbies like me.

 

Production Last Year = 

VAR CurrentYear =

    MAX ( calendar[FiscalYear] )

VAR LastYear = CurrentYear - 1

RETURN

    CALCULATE (

        [Produccion];

        FILTER ( ALL ( 'Calendar' ); 'Calendar'[FiscalYear] = LastYear)

    )

View solution in original post

4 REPLIES 4

You could write a custom time intelligence functions to do this

Sales Current Year =
VAR CurrentYear =
    MAX ( calendar[year] )
RETURN
    CALCULATE (
        [Total Sales],
        FILTER ( ALL ( calendar ), calendar[Year] = CurrentYear )
    )

and this

Sales Last Year =
VAR CurrentYear =
    MAX ( calendar[year] )
VAR LastYear = CurrentYear - 1
RETURN
    CALCULATE (
        [Total Sales],
        FILTER ( ALL ( calendar ), calendar[Year] = LastYear)
    )

You can read my article about time intelligence in Power BI here 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi @MattAllington 

Thank you very much for answering. Following your tip I have applied your measure to my model and it gives me a wrong result as I am working with fiscal year ( from 1s july to 30th june). Following the logical, if I change Calendar[Year] for Calendar[FiscalYear], the result is an error. May be is because Calendar[FiscalYear] in the calendar table is difined as FY16, FY17... FY20, but I don´t know how to solve it.

 

By the way, I have take a look to your article and I find it very interesting. Its very helpfull for  newbies like me.

 

Production Last Year = 

VAR CurrentYear =

    MAX ( calendar[FiscalYear] )

VAR LastYear = CurrentYear - 1

RETURN

    CALCULATE (

        [Produccion];

        FILTER ( ALL ( 'Calendar' ); 'Calendar'[FiscalYear] = LastYear)

    )

You need an integer FY column. Just add one to your calendar as a calc column

 

FY = right(calendar[fiscalyear],2)



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Thank you @MattAllington  it works!

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.