Forum Discussion

Kopek's avatar
Kopek
Icon for Helper IV rankHelper IV
1 year ago
Solved

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:

 

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)

 

9 Replies

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

    How do you compute the difference between four values?

  • 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.

    • lbendlin's avatar
      lbendlin
      Icon for Super User rankSuper User

      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.

      • Kopek's avatar
        Kopek
        Icon for Helper IV rankHelper IV

        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,..

    • Anonymous's avatar
      Anonymous
      Not applicable

      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