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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Kopek
Helper IV
Helper IV

Calculate difference between columns in the matrix

Hi,

 

I have the following dataset:

 

DateCategoryValue

01/01/2020Category 1100
01/01/2020Category 12
01/01/2020Category 23
01/01/2020Category 356
01/01/2020Category 376
01/01/2020Category 212
01/03/2020Category 356
01/03/2020Category 434
01/03/2020Category 478
01/03/2020Category 178
01/03/2020Category 29
01/01/2021Category 212
01/01/2021Category 25
01/01/2021Category 134
01/01/2021Category 167
01/01/2021Category 318
01/01/2021Category 399

 

Out of which i  create a simple matrix:

 

Kopek_0-1730457117877.png

Now i want to add 2 additional columns difference and diif% at the end which will count difference in column based on selected categories and if all selected based on all selcted, can ypou help me with dax please ?

e.g 
Cat 1 and 2 selected, outcome:

01/01/2020 difference 87 (102-15)
01/01/2021  difference 84 (101-17)

01/03/2020 difference 69 (78-9)

 

1 ACCEPTED SOLUTION
Kopek
Helper IV
Helper IV

Found a solution.

In case anyone stucked here is a good starting point: Solved: Difference instead of Total in PowerBI Matrix - Microsoft Fabric Community

View solution in original post

9 REPLIES 9
Kopek
Helper IV
Helper IV

Found a solution.

In case anyone stucked here is a good starting point: Solved: Difference instead of Total in PowerBI Matrix - Microsoft Fabric Community

Hi,@Kopek 
Thank you for sharing the challenges you've faced. We're thrilled that you've found a solution and appreciate your openness to exploring others' ideas. This insight is invaluable for community members dealing with similar issues.

 

Once again, thank you for your efforts.

 

Wishing you all the best!

 
Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
 

Best Regards,

Leroy Lu

Kopek
Helper IV
Helper IV

Hi @lbendlin - that's actually a fair point... 
So let's say we will limit selection to 2 categories only, but how to make it dynamic, as the configuration might be different, one may select Category 1 and 2, other one Category 1 &3 and other one 4&2 and so on... and we want to compute the difference and diff % between selected categories.. hope it makes sense.

I would go with Visual Calculations - they have a concept of PREVIOUS  where you can look sideways in a visual and compare to the neighboring values.

not sure it will work either as we want to have one column for difference and one for diff%, not category columns split by new columns,..

Correct, you can only abuse the Column Totals once.  

 

You would be looking into creating a custom matrix with a reference table for the desired column names and a measure to do the switching. This becomes very ugly very quickly and is frankly not worth the effort.

so.. there is no simple solution to this ?

looks like it should not be that complicated... total is computed somehow, so why we are not ab;eto overwitte it with difference or something like this ?:(

Because as you said - you would have to add the additional measures to each of the columns (categories).  You cannot "add columns to a matrix" - that's not a thing. Power BI is not Excel.

lbendlin
Super User
Super User

based on selected categories and if all selected based on all selcted

How do you compute the difference between four values?

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!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.