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

Cleanest way to do YoY calculations for financial year starting in July

Hi,

I live in Australia so our financial year starts in July. I've found it surprisingly difficult to get YoY and YTD calculations to work using standard formulas in Power BI. I'm also not having much luck searching these forums. I have colleagues who have created workarounds but they seem pretty messy and complicated, so I was hoping to refer here for the cleanest possible way to do these calculations.

 

So making this as simple as possible, let's say I have a sales table aggregated by week, and a date table. Below is some dummy data for the first three weeks of financial year 2020 and 2021, and also the week preceding those dates. Note the need to use a custom date table that supplies what the equivalent week is from last year. This is because some financial years have 53 weeks and so you need to keep track of that historically, I have noticed this can mess up calculations using the standard formulas in Power BI. See tables below:

 

This year weekSales
202152400
202201600
202202500
202203700
202052300
202101500
202102400
202103600

 

Financial weekPrevious year financial weekDate

202152

202052June 24 2021

202201

202101July 1 2021
202202202102July 8 2021
202203202103July 15 2021
202052201952June 25 2020
202101202001July 2 2020
202102202002July 9 2020
202103202003July 16 2020

 

So what I need is as follows:

 

  • Calculated field that returns sales an growth for the past 52 weeks and YTD for financial year starting in July
  • Calculated field that returns sales and growth for previous 52 weeks and previous YTD for financial year starting in July
  • Ability to enter these fields into a KPI visual so it shows this year, last year and growth
  • Ability to enter these fields into a line graph so it shows this year and last year sales using the same axis, with this year's date on the X axis

So the above example should return the following:

 

  • YoY sales this year: 2200, YTD sales this year: 1800
  • YoY sales last year: 1800, YTD sales last year: 1500
  • YoY growth: 22%, YTD growth: 20%
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @htipene 

 

You can try the following methods.

 

Sales =
LOOKUPVALUE ( Sales[Sales], 'Financial week'[Financial week], [Financial week] )

 

vzhangti_0-1637656232521.jpeg

 

YoY sales = 
CALCULATE (
    SUM ( 'Financial week'[Sales] ),
    FILTER (
        'Financial week',
        [Date].[Year] = EARLIER ( 'Financial week'[Date].[Year] )
    )
)
YTD sales = 
CALCULATE (
    SUM ( 'Financial week'[Sales] ),
    FILTER (
        'Financial week',
        [Date].[MonthNo] = 7
            && [Date].[Year] = EARLIER ( 'Financial week'[Date].[Year] )
    )
)

 

vzhangti_1-1637656287341.png

vzhangti_2-1637656308716.png

 

 

YoY growth =
DIVIDE (
    MAX ( 'Financial week'[YoY sales] ) - MIN ( 'Financial week'[YoY sales] ),
    CALCULATE (
        MAX ( 'Financial week'[YoY sales] ),
        FILTER ( ALL ( 'Financial week' ), [Date].[Year] = 2020 )
    )
)
YTD growth = 
DIVIDE (
    MAX ( 'Financial week'[YTD sales] ) - MIN ( 'Financial week'[YTD sales] ),
    CALCULATE (
        MAX ( 'Financial week'[YTD sales] ),
        FILTER ( ALL ( 'Financial week' ), [Date].[Year] = 2020 )
    )
)

 

vzhangti_3-1637656363805.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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-zhangti
Community Support
Community Support

Hi, @htipene 

 

You can try the following methods.

 

Sales =
LOOKUPVALUE ( Sales[Sales], 'Financial week'[Financial week], [Financial week] )

 

vzhangti_0-1637656232521.jpeg

 

YoY sales = 
CALCULATE (
    SUM ( 'Financial week'[Sales] ),
    FILTER (
        'Financial week',
        [Date].[Year] = EARLIER ( 'Financial week'[Date].[Year] )
    )
)
YTD sales = 
CALCULATE (
    SUM ( 'Financial week'[Sales] ),
    FILTER (
        'Financial week',
        [Date].[MonthNo] = 7
            && [Date].[Year] = EARLIER ( 'Financial week'[Date].[Year] )
    )
)

 

vzhangti_1-1637656287341.png

vzhangti_2-1637656308716.png

 

 

YoY growth =
DIVIDE (
    MAX ( 'Financial week'[YoY sales] ) - MIN ( 'Financial week'[YoY sales] ),
    CALCULATE (
        MAX ( 'Financial week'[YoY sales] ),
        FILTER ( ALL ( 'Financial week' ), [Date].[Year] = 2020 )
    )
)
YTD growth = 
DIVIDE (
    MAX ( 'Financial week'[YTD sales] ) - MIN ( 'Financial week'[YTD sales] ),
    CALCULATE (
        MAX ( 'Financial week'[YTD sales] ),
        FILTER ( ALL ( 'Financial week' ), [Date].[Year] = 2020 )
    )
)

 

vzhangti_3-1637656363805.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

MFelix
Super User
Super User

Hi @htipene ,

 

On the time inteliggence calculations there is an optional parameter that is the fiscal month, so you can select where the year starts and end:

 

DATESYTD(<dates> [,<year_end_date>])

Term Definition
dates A column that contains dates.
year_end_date

(optional) A literal string with a date that defines the year-end date. The default is December 31.

 

TOTALYTD(<expression>,<dates>[,<filter>][,<year_end_date>])

PARAMETERS
Parameter Definition
expression An expression that returns a scalar value.
dates A column that contains dates.
filter (optional) An expression that specifies a filter to apply to the current context.
year_end_date (optional) A literal string with a date that defines the year-end date. The default is December 31.

 

Taking into account you have Date and a Date table you can sinply add that parameter value to your calculation

 

Check documentatio below for both of the DAX above.

 

https://dax.guide/datesytd/

https://dax.guide/totalytd/

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.