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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
MattAllington
Community Champion
Community Champion

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.
I will not give you bad advice, even if you unknowingly ask for it.

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
MattAllington
Community Champion
Community Champion

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.
I will not give you bad advice, even if you unknowingly ask for it.

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.
I will not give you bad advice, even if you unknowingly ask for it.

Thank you @MattAllington  it works!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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