cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JeffF Frequent Visitor
Frequent Visitor

YoY difference on Year (Whole Number) field, Not Date field

Hi, I'm relatively new to DAX and have a challenge...I have a file with a Year column (no month, no day in any other column). I can't change the year to a date or all years turn to 1905. I want to do a YoY % change calculation. I've tried multiple versions of measures and no luck. Here's a sample of the data:Sample Raw Data.GIF

 

 

And here's the desired output:Sample Output.GIF

Any guidance is appreciated. TIA!

Best,

Jeff

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Phil_Seamark Super Contributor
Super Contributor

Re: YoY difference on Year (Whole Number) field, Not Date field

Hi @JeffF

 

Please add the following calculated measure to your model.  I have loaded a PBIX file for you to play with.

 

% Change = 
VAR varThisYear = [Sum of Amount]
VAR varLastYear = 
    CALCULATE(
        [Sum of Amount] ,
        FILTER(
                ALL('Table1'[FiscalYear]),
                'Table1'[FiscalYear] = MAX('Table1'[FiscalYear]) - 1)
                )
RETURN DIVIDE(varThisYear - varLastYear,varLastYear)    

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
Phil_Seamark Super Contributor
Super Contributor

Re: YoY difference on Year (Whole Number) field, Not Date field

Hi @JeffF

 

Please add the following calculated measure to your model.  I have loaded a PBIX file for you to play with.

 

% Change = 
VAR varThisYear = [Sum of Amount]
VAR varLastYear = 
    CALCULATE(
        [Sum of Amount] ,
        FILTER(
                ALL('Table1'[FiscalYear]),
                'Table1'[FiscalYear] = MAX('Table1'[FiscalYear]) - 1)
                )
RETURN DIVIDE(varThisYear - varLastYear,varLastYear)    

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

Phil_Seamark Super Contributor
Super Contributor

Re: YoY difference on Year (Whole Number) field, Not Date field

And if you want to convert your fiscal year column to a date use the following function, which will create a value of 1st Jan for the particular year (you can use different numbers as the 2nd and 3rd parameters if you would like to pick a date that coincided with your financial year.

 

= DATE( 'Table1'[FiscalYear] , 1, 1)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hardik Established Member
Established Member

Re: YoY difference on Year (Whole Number) field, Not Date field

Screenshot_6.pngHope this helps

JeffF Frequent Visitor
Frequent Visitor

Re: YoY difference on Year (Whole Number) field, Not Date field

Thanks so much, Phil!!!

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 56 members 1,159 guests
Please welcome our newest community members: