cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hudg16
Helper I
Helper I

Dividing Two Numbers

Hey folks, 

Trying to divide one value in a column by another not having any luck...

Thanks in advance!

Hudg16_0-1633460535927.png

 

1 ACCEPTED SOLUTION

Hi @Hudg16 ,

 

You will need to create this as a Measure, and not a calculated column, the calculated column is evaluated in the contex of each row in the underlying table rows, and each row has a [new] value of 1. In other words the spend on each row is being divided by 1 for each row when the column is created and when the model is processed, then the matric sums up the value in the already computed column value, nets to the same value as spend. The Measure will be evalutated in the context of the filter, query and visual. I am not likely providing a great explanation, here is are links to a couple good article for your review.

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/ 

https://support.microsoft.com/en-us/office/context-in-dax-formulas-2728fae0-8309-45b6-9d32-1d600440a... 

 

richbenmintz_1-1633471310390.png

see results below

 

richbenmintz_0-1633471277471.png

 



I hope this helps,
Richard

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

Proud to be a Super User!


View solution in original post

6 REPLIES 6
richbenmintz
Super User
Super User

Hi @Hudg16 ,

 

Assuming you are creating a measure, the formula would look like

 

Avg New Activation Spend = Divide(sum(Data[New Activiation Spend]), sum(Data[New]))

 

 



I hope this helps,
Richard

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

Proud to be a Super User!


@richbenmintz 

Hudg16_0-1633463430525.png
Not sure what I am missing here haha. I am expecting 500/2 = 250. 

 

Hi @Hudg16 ,

 

Can u create two measures:

Act Spend = sum(Data[New Activiation Spend])
New Act = sum(Data[New])

then add those to the Matrix, would like to see the values they generate



I hope this helps,
Richard

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

Proud to be a Super User!


Hi @Hudg16 ,

 

Can you provide a link to a sample pbix file or sample data and a screen shot of your model, sample file would be best



I hope this helps,
Richard

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

Proud to be a Super User!


@richbenmintz Pbix is attached, ive just narrowed it down to new in this case. Thanks for your help 
https://we.tl/t-zGeqYH87GO

Hi @Hudg16 ,

 

You will need to create this as a Measure, and not a calculated column, the calculated column is evaluated in the contex of each row in the underlying table rows, and each row has a [new] value of 1. In other words the spend on each row is being divided by 1 for each row when the column is created and when the model is processed, then the matric sums up the value in the already computed column value, nets to the same value as spend. The Measure will be evalutated in the context of the filter, query and visual. I am not likely providing a great explanation, here is are links to a couple good article for your review.

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/ 

https://support.microsoft.com/en-us/office/context-in-dax-formulas-2728fae0-8309-45b6-9d32-1d600440a... 

 

richbenmintz_1-1633471310390.png

see results below

 

richbenmintz_0-1633471277471.png

 



I hope this helps,
Richard

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

Proud to be a Super User!


View solution in original post

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

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

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors