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
Anonymous
Not applicable

Difference and Variance between 2 columns in a Matrix

I have looked at different solutions to this, but none have worked for me:

 

I have a martix with the total number of forms per year for each row. I want to add a column that calculates the difference per year by row, and also a column that lists the variance by row. 

 

Example:

 

Source     2016     2017     Difference      Variance

_______     ______   _______   ___________      ___________

eCom     40          25         - 15                   -46.2% 

ad          20          30            10                       40%

email     10          45            35                   127.3% 

 

I currently have this:

 

Untitled.png

 

What measurements/calculated columns should I be creating to get the desired results?

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@Anonymous,


Do you have source table as shown in the following screenshot?
1.PNG

If so, create a new table using DAX below.

Table = SUMMARIZE(SourceTable,SourceTable[Source],SourceTable[Year],"Value",SUM(SourceTable[Value]))

Then create the following columns in the new table and create a Matrix visual.

Previous = CALCULATE(MAX('Table'[Value]),FILTER('Table','Table'[Source]=EARLIER('Table'[Source])&& 'Table'[Year]<EARLIER('Table'[Year])))
diff = IF(ISBLANK('Table'[Previous]),0, 'Table'[Value]-'Table'[Previous])
2.PNG

 

Besides, what logic do you use to calculate Variance?

Regards,

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.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous

Do you have a calendar dimension aka data table in use?

 

v-yuezhe-msft
Employee
Employee

@Anonymous,


Do you have source table as shown in the following screenshot?
1.PNG

If so, create a new table using DAX below.

Table = SUMMARIZE(SourceTable,SourceTable[Source],SourceTable[Year],"Value",SUM(SourceTable[Value]))

Then create the following columns in the new table and create a Matrix visual.

Previous = CALCULATE(MAX('Table'[Value]),FILTER('Table','Table'[Source]=EARLIER('Table'[Source])&& 'Table'[Year]<EARLIER('Table'[Year])))
diff = IF(ISBLANK('Table'[Previous]),0, 'Table'[Value]-'Table'[Previous])
2.PNG

 

Besides, what logic do you use to calculate Variance?

Regards,

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.

Lydia Zhang

Having the same issue, and I have it down to what is shown in your output.  But I do not want the diff to been shown with what you have as 2016 data.  I have many columns to show and the additional columns are not required.

Currently I have sales data for 2017, 2018 and 2019.  I want to show the difference between 2017 and 2018 which I have a measure for and it's working correctly.  However that measure shows up under 2017, 2018 and 2019 and is only required under 2018.

This seems like something that should be so easy, yet seems so difficult.

BTW very new to Power BI so I must be missing some easy trick.

JC.

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.