Reply
Fusilier2
Advocate II
Advocate II
Partially syndicated - Outbound

Help with year on year calculation

Hi,

Hope somebody ca nhelp me?

I have this working measure:

 

% Count Agree = DIVIDE( SUM('Append'[Count Agree]) , CALCULATE(SUM('Append'[Answer count]),all('Append'[Aggregated answers])))
 
There is a year column in the 'Append' table (with two years worth of data: 2023 and 2024) linked to a calendar table.
I want to calculate a year on year difference? I presume I would need two measures one for 2024 and one for 2023 and deduct one from the other. So, how would I adapt the existing measure to create one measure for 2024 and one for 2023?
 
Thanks!
1 ACCEPTED SOLUTION
v-xuxinyi-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Fusilier2 

 

Thanks for the reply from SachinNandanwar .

 

Fusilier2 , the following testing is for your reference. 

 

My sample:

vxuxinyimsft_0-1726798380527.png

 

Create two measures as follow.

LastYear = 
VAR _LastYear = MAX([Year]) - 1
VAR _sum = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Year] = _LastYear))
RETURN
_sum

 

Divide = 
VAR _MaxYear = MAX([Year])
VAR _sum = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Year] = _MaxYear))
RETURN
DIVIDE(_sum, [LastYear])

 

Output:

vxuxinyimsft_1-1726798603692.png

 

If the data structure I use is different from what you use, please provide some sample data and the expected results based on the sample data so that we can better help you. How to provide sample data in the Power BI Forum - Microsoft Fabric Community  Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.

 

Best Regards,
Yulia Xu

 

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

4 REPLIES 4
v-xuxinyi-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Fusilier2 

 

Do the methods offered so far solve your problem? If so, could you please mark helpful answers as solutions? This will help more users who are facing the similar difficulties. Thank you!

 

Please feel free to let me know if the problem persists.

 

Best Regards,
Yulia Xu

Ashish_Mathur
Super User
Super User

Syndicated - Outbound

Hi,

The relationship should be between the Date column of the Append table to the Date column of the Calendar Table.  In the Calendar table, create a Year column and drag Year from the Calendar table to your visuals/filtes/slicers.  Select 2024.  Write these measures

% count agree LY = calculate([% count agree],previousyear(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-xuxinyi-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Fusilier2 

 

Thanks for the reply from SachinNandanwar .

 

Fusilier2 , the following testing is for your reference. 

 

My sample:

vxuxinyimsft_0-1726798380527.png

 

Create two measures as follow.

LastYear = 
VAR _LastYear = MAX([Year]) - 1
VAR _sum = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Year] = _LastYear))
RETURN
_sum

 

Divide = 
VAR _MaxYear = MAX([Year])
VAR _sum = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Year] = _MaxYear))
RETURN
DIVIDE(_sum, [LastYear])

 

Output:

vxuxinyimsft_1-1726798603692.png

 

If the data structure I use is different from what you use, please provide some sample data and the expected results based on the sample data so that we can better help you. How to provide sample data in the Power BI Forum - Microsoft Fabric Community  Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.

 

Best Regards,
Yulia Xu

 

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

SachinNandanwar
Super User
Super User

Syndicated - Outbound

You could use SAMPLEPERIODLASTYEAR function

YourMeasure= CALCULATE(
[% Count Agree],
SAMEPERIODLASTYEAR('Calendar'[Date])
)

 



Regards,
Sachin
Check out my Blog
avatar user

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)