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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lnjwilliamson86
Frequent Visitor

Calculating % Variance between YTD & LYTD

Hi, 

 

I am trying to calculate the variance % between a YTD and LYTD. However my formulas are giving me incorrect results. 

I have monthly data over two financial years for various metrics in my dataset

 

The forumulas I have used are listed below. 

 

YTD= TOTALYTD(SUM[metric],'date'[date],"06/30")

LYTD =CALCULATE([metric],DATEADD('date'[date],-1,year))

Variance = [LYTD]-[YTD]

% Variance = DIVIDE([Variance],[LYTD]

 

Is there some sort of date field required in the variance and % variance formulas? 

 

Thanks

 

 

2 ACCEPTED SOLUTIONS

Hi,

 

You will have to select a month for the TOTALYTD() function to work.  Only then will it know where it has to sum till.  If your Financial Year starts on July 1 and you select October as the month in the filter/slicer, your measure will sum up the numeric column from JUly 1 to October 31.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
lnjwilliamson86
Frequent Visitor

After some further investigating (aka messing around) I have realised that if i select the three months in this FY to date in a visual level filter the variance and % variance results work. 

 

Can someone help me with some DAX code to ensure that my variance and % variance measures will work so that I don't need to use the month visual level filter. 

 

 

Thanks 🙂 

Hi,

 

You will have to select a month for the TOTALYTD() function to work.  Only then will it know where it has to sum till.  If your Financial Year starts on July 1 and you select October as the month in the filter/slicer, your measure will sum up the numeric column from JUly 1 to October 31.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @Ashish_Mathur.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@lnjwilliamson86,

Do you drag year field to your visual? And when calculating LYTD, I use the following DAX. I note that you use this formula instead:LYTD =CALCULATE([metric],DATEADD('date'[date],-1,year)). Do you create another measure named metric?

LYTD =CALCULATE([YTD],DATEADD('date'[date],-1,year))

1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yuezhe-msft,

 

My LYTD Calcualtion does use the YTD Metric (see actual formulae below) . However when I put my data into a table format I can see that the LYTD is giving me the sum of the full year not just the first quarters data.

 

Capture2.PNG

 

See actual formulae below.

 

6. YTD Water Consumption Billed = TOTALYTD(sum(Datasheet[6. Total water consumption billed (based on Levy data)]),'Date'[Date],"06/30")

 

6. LYTD Total Water Consumption Billed = CALCULATE(Datasheet[6. YTD Water Consumption Billed],DATEADD('Date'[Date],-1,year))

 

Water Consumption Variance = [6. YTD Water Consumption Billed]-[6. LYTD Total Water Consumption Billed]

 

Water Consumption Variance % = DIVIDE([Water Consumption Variance],[6. LYTD Total Water Consumption Billed])

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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