Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Dividing rows

Hi All,

 

Table is set up like this.

 

measure 1      measure 2     year 1    year 2    year 3

Flower            rose               5            3           1

Flower            lily                 0             1          6

Flower            aster              2            5           4

Trees              pine               3            5           8

Flower            coconut         2            6           0

Flower            mango          9             7          3

 

Now I want to divide the total sum of Flower with regards to trees sum(flower)/sum(trees) such that the table will show

 

measure 1       year 1    year 2    year 3

Flower/trees      2            2           1

 

how do I create a dax measure to divide rows?

 

Thank you!

 

Kind Regards,

 

  • You should unpivot your year columns.

     

    Then you can do something like this:

     

    Flowers/trees = CALCULATE(SUM('FlowersTrees'[Value]),'FlowersTrees'[Measure1]="Flower")/ CALCULATE(SUM('FlowersTrees'[Value]),'FlowersTrees'[Measure1]="Trees")

    I do not get the numbers that you presented in your solution though from the data you provided.

1 Reply

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    You should unpivot your year columns.

     

    Then you can do something like this:

     

    Flowers/trees = CALCULATE(SUM('FlowersTrees'[Value]),'FlowersTrees'[Measure1]="Flower")/ CALCULATE(SUM('FlowersTrees'[Value]),'FlowersTrees'[Measure1]="Trees")

    I do not get the numbers that you presented in your solution though from the data you provided.