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
Shackwell
Helper III
Helper III

Calculations between 2 matrix

Hello fine gentlemen of the web,

 

Currently I have the following scenario. I have 2 matrix in a report page, where the rows are the departments and for columns I have the 12 months of the year. One matrix is from 2020 and the other is from 2021. Im trying to show a third matrix with calculations of variance and the monetary difference as well. Any jelp would be appreciated. 

 

 

1 ACCEPTED SOLUTION

@Shackwell in this case, you simply need to create few measures like below

 

2021_Val = calculate(SUM(facts[value]),facts[year]=2021)
2020_Val = calculate(SUM(facts[value]),facts[year]=2020)
Variance = facts[2021_Val]-facts[2020_Val]
variance% = facts[2021_Val]/facts[2020_Val]-1
 
then simily put these measures in your matrix and you get below visual 
negi007_0-1638011166164.png

also since for calc variance we would need date as well so i have created date basis month as well like first day of each month

 

i am also attaching pbix file for your reference

 

i hope it help you 




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



Proud to be a Super User!


Follow me on linkedin

View solution in original post

6 REPLIES 6
Shackwell
Helper III
Helper III

Yes this is great to get me started. I just have a question for one of the strings of the formula. =Calculate(sum(FACTS). What does the Fact operation have to do in here? I think I understood the rest without issues.

@Shackwell 

if you want sum of values for a year or basis some critria, you use calculate function and second argumnet is the filter criteria like below. facts is basically is the name of the table and value is the column which is being used for sum

2021_Val = calculate(SUM(facts[value]),facts[year]=2021)

 

if you just need the sum of values from facts table, then you can use simply sum(facts[value])




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



Proud to be a Super User!


Follow me on linkedin

negi007
Community Champion
Community Champion

@Shackwell will it be possible for you to share some dummy sample data with the expected output. this will help you in a better way.




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



Proud to be a Super User!


Follow me on linkedin

So here in the sample data you can see the first 2 matrix being filled with departments as rows and months as columns. I want to create a calculation between matrix, having the 3rd matrix doing a substraction between and the 4th matrix to show a percentage change in the given period. Im not sure if you wanted to see the desired output or you wanted to see how is data being added? thanks again,

 

Screen Shot 2021-11-26 at 10.24.08.png

@Shackwell in this case, you simply need to create few measures like below

 

2021_Val = calculate(SUM(facts[value]),facts[year]=2021)
2020_Val = calculate(SUM(facts[value]),facts[year]=2020)
Variance = facts[2021_Val]-facts[2020_Val]
variance% = facts[2021_Val]/facts[2020_Val]-1
 
then simily put these measures in your matrix and you get below visual 
negi007_0-1638011166164.png

also since for calc variance we would need date as well so i have created date basis month as well like first day of each month

 

i am also attaching pbix file for your reference

 

i hope it help you 




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



Proud to be a Super User!


Follow me on linkedin

Hello there,

 

We are almost there. I have managed to get the measures going but I have encountered the following. There might be some spaces with 0 number allocation, so whenever Im trying to divide I get that the result is infinite. Also there's a month before January in the report marked as blanks but still shows calculation within the departments. 

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.