Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Calculate % difference between Column Values in Matrix

Hi,

 

I am using the Matrix Visual to display 2 dimensional data. In the columns I have Month and in the Rows I have the url's visited by the user. The values section  shows the count of distinct users who have visited a particular url in the month. However I am now looking to create another column to show the % difference in the number of distinct user going up and down for each url. For example the data looks like this

                Jan            Feb

Home       20              40

Product    10              30

 

How can I add a % difference column. In Excel this can be easily achieved by referencing the cell. Is there a similar way to achieve this in DAX ?

 

 

2 Replies

  • kentyler's avatar
    kentyler
    Solution Sage

    DAX has no concept of cells, but it does have a concept of Rows. You could probably add a calculated column something like this:

     

    FebChangePercent = DIVIDE(<data_table_name>[<jan_data_column>], 

    <data_table_name>[<feb_data_column>])

    You would have to write a calculated column for each pair of months you want to calculate the percent of change for.

    I did not address the order you want to do the division in or the formatting of the result.

     

    • kentyler's avatar
      kentyler
      Solution Sage

      If you are using measures to calculate the totals in your rows, then you can use the measure names instead of the table_name[column_name] syntax i showed.

      FebPercentChange := FORMAT(

                                       DIVIDE( Jan_total, Feb_total,0),

                                       "percent"

                                                     )