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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anon2020
Helper I
Helper I

Matrix Showing Difference Between Two Years

I have a matrix, shown below, that I want to show the difference between the two selected years. I am unsure of the formula to calculate the difference, but when I add it to the values of the matrix, the result shows the difference btween the tweo sets of data. Here is an example of what I am looking for:

 

Anon2020_1-1755631970900.png

 

 

 

 

 

Anon2020_0-1755631838500.png

 

1 ACCEPTED SOLUTION
v-hashadapu
Community Support
Community Support

Hi @Anon2020 , Thank you for reaching out to the Microsoft Fabric Community Forum.

 

I reproduced the scenario on my end using sample data and it worked successfully. To help you better understand the implementation, I’ve attached the .pbix file for your reference. Please take a look at it and let me know your observations.

 

Thank you for being part of the Microsoft Fabric Community!

View solution in original post

19 REPLIES 19
v-hashadapu
Community Support
Community Support

Hi @Anon2020 , Hope you're doing fine. Can you confirm if the problem is solved or still persists? Sharing your details will help others in the community.

v-hashadapu
Community Support
Community Support

Hi @Anon2020 , Hope you're doing okay! May we know if it worked for you, or are you still experiencing difficulties? Let us know — your feedback can really help others in the same situation.

v-hashadapu
Community Support
Community Support

Hi @Anon2020 , Thank you for reaching out to the Microsoft Fabric Community Forum.

 

I reproduced the scenario on my end using sample data and it worked successfully. To help you better understand the implementation, I’ve attached the .pbix file for your reference. Please take a look at it and let me know your observations.

 

Thank you for being part of the Microsoft Fabric Community!

v-hashadapu
Community Support
Community Support

Hi @Anon2020 , hope you are doing great. May we know if your issue is solved or if you are still experiencing difficulties. Please share the details as it will help the community, especially others with similar issues.

Also, your sample data links doesn't work, so if your issue is not solved. can you please re-send them. 

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


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

Let me know if you have troublke accessing the link

Hello @Anon2020 ,

 

The link does not work. Please store the pbix file in a Google drive (with public permissions) or a Dropbox (again public) or a public repo in Github whichever you prefer. Please make sure that you remove any sensitive data beforehand. 
Or, you could simply add sample data in a table format (that can be copied so not an image) and drop the measure definitions (if any) or any particular steps to recreate your visual. 

That is not a downoadable file link.  That link takes me to a sign-in page.


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

do you have an email I can send to? It is in my org's salesforce environment

Anon2020
Helper I
Helper I

Anon2020_0-1755632882328.png

this is as close as I can get, but still not showing difference, and still showing values between fiscal years instead of in the last column

 

@Anon2020 You would need to get the Maximum and Minimum values for the Opp_FY_c column. Then you would need to have 2 CALCULATE statements where you calculate the SUM for the TotalPrice column, once for the Maximum value and once for the Minimum value. Modify your filter clause within each CALCULATE statemetn. Then you simply need to subtract one from the other.

would be be so kind to show me?

@Anon2020 I can certainly endeavor to do so. 

Measure = 
  VAR _maxFY = MAX( Opportunity[Opp_FY_c] )
  VAR _minFY = MIN( Opportunity[Opp_FY_c] )
  VAR _sumMaxFY = CALCULATE( SUM( 'Opportunity Product'[TotalCost] ), Opportunity[Opp_FY__c] = _maxFY )
  VAR _sumMinFY = CALCULATE( SUM( 'Opportunity Product'[TotalCost] ), Opportunity[Opp_FY__c] = _minFY )
  VAR _return = _sumMinFY - _sumMaxFY
RETURN
  _return

Hopefully this gets you the answer you are looking for or at least gets you close enough.

Anon2020_0-1755647632886.png

 

I keep thrwoing zeros, and do not know why. Can I send you the pbix file?

 

The other thing is that I do not want two Diff Year Columns. Only one, on the right side of the matrix

@Anon2020 Ah, I believe it should be this instead:

Measure = 
  VAR _maxFY = CALCULATE( MAX( Opportunity[Opp_FY_c] ), ALLSELECTED( 'Opportunity' ) )
  VAR _minFY = CALCULATE( MIN( Opportunity[Opp_FY_c] ), ALLSELECTED( 'Opportunity' ) )
  VAR _sumMaxFY = CALCULATE( SUM( 'Opportunity Product'[TotalCost] ), Opportunity[Opp_FY__c] = _maxFY )
  VAR _sumMinFY = CALCULATE( SUM( 'Opportunity Product'[TotalCost] ), Opportunity[Opp_FY__c] = _minFY )
  VAR _return = _sumMinFY - _sumMaxFY
RETURN
  _return

If you would prefer a single year column then it you would likely benefit from making this a Table visual rather than a Matrix visual.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors