cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vanquisher11
Frequent Visitor

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,

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User IV
Super User IV

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.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
Greg_Deckler
Super User IV
Super User IV

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.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors