Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Difference between two groups in the same column

I have data similar to the following

 

Group

Value

1

25
125
334
334
334
427
427
755
755

 

Essentially, every value in [Group] has the same value in [Value]. Now, I need to use DAX to create a formula column capable of calculating the slope between each represented group. It should work like this:

((Value of Group)-(Value of next lowest Group)) / ((Group)-(Next Lowest Group))

 

Ex: (55-27)/(7-4) = 28/3 = 9.3

     (27-34)/(4-3) = -7/1 = -7

  • I created a rank column and a measure like given below

     

    Column = RANKX(Sheet1,Sheet1[Group],,DESC,Dense)
    Measure = divide(maxx(FILTER(Sheet1,Sheet1[Column]=1),Sheet1[Value])-maxx(FILTER(Sheet1,Sheet1[Column]=2),Sheet1[Value]),maxx(FILTER(Sheet1,Sheet1[Column]=1),Sheet1[Group])-maxx(FILTER(Sheet1,Sheet1[Column]=2),Sheet1[Group]))

     

    You can create one more for the second. Unless you were looking for some other display.

     

    Link : https://www.dropbox.com/s/p3ewc9h970503qh/groupRank.pbix?dl=0

4 Replies