Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
mbhunt
Regular Visitor

Divide two columns in a group by.

Sorry, I know this seems so simple, but I can’t figure it out.

 

In the following example, how do I take the [ListPriceExtended] and divide it by the [Qty] to get the [AverageListPrice] for each line? 

 

snip1.jpg

The Qty and ListPriceExtended columns are Sum columns and we are grouping based on SKU.  My AverageListPrice is a measure with the following expression:

 

AverageListPrice = SUM(MarkDownRaw[ListPriceExtended]) / SUM(MarkDownRaw[Qty])

 

However, the SUM statements are taking the sum of the full table, and not just the sum for each group by.

 

Here is the breakdown for SKU 70013.  The Sum of the ListPriceExtended is $334.48 and the Sum of the Qty is 46, so the AverageListPrice should be $334.48 / 46 for an average list price of $7.27.

 

snip2.jpg

Thanks much!

1 ACCEPTED SOLUTION

I think I know where you went wrong - did you add AverageListPrice as a "New measure" or a "New column"?  It looks like "New column", but it should likely be a "New measure".

View solution in original post

5 REPLIES 5
mike_honey
Memorable Member
Memorable Member

Your formula looks correct to me.  I imagine there must be other data Tables involved in that Table visual, with a missing or incorrect relationship?

Thanks for the reply. 

 

So is "SUM" supposed to take the Sum of the entire table or just the group by section (which is what I want)?

 

Thanks.

I think I know where you went wrong - did you add AverageListPrice as a "New measure" or a "New column"?  It looks like "New column", but it should likely be a "New measure".

Looks good.  I think I got it.  Thanks.

I think Mike has nailed it..   I made a simple demo and made a calculated column and measure.  The column reprecates your what your seeing, but the measure actually meets your requirements.

Capture.PNG

 Try remaking your calculation as a new measure:New Measure.png

 

 

 

 

 

 

 

 

 

Mike Carlo

www.PowerBI.Tips

mike@powerbi.tips

Mike Carlo ( https://powerbi.tips )
mike@PowerBI.Tips

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.