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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
fong
New Member

Sum of a measure in a column

I need some help in the below model. I need to calculate a volume in SQM (which is length x width) and average selling price per sqm. The rows add up fine but I also need a total volume and ASP/SQM for a category of SKU's to be reflected in the visualizations as well. A snapshot and the formula I currently used is below. Will appreciate some help on this. 

 

 IDQuantitySalesASP per SQM =sales / sum(Quantity)*average(width)*average(length)Width (m)Length (m)Volume (SQM) = sum(Quantity)*average(width)*average(length)
114500$84,903.29$34.240.01992479.5
239100$256,616.62$34.540.019107429
316950$76,578.69$23.780.019103220.5
48448$17,362.31$21.630.0195802.56
56480$5,700.18$23.150.0192246.24
689010$328,210.15$19.410.0191016911.9
788150$565,387.91$36.890.0199.1515324.8775
8173001$306,680.29$46.650.01926574.038
Correct value4356391641439.44$30.98                                     52,988.62
PBI showing  $11.09 0                                147,960.00
1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @fong ,

 

You may create new measure like DAX below to get correct total sum for the [ASP per SQM].

 

ASP per SQM_New=

var _table = SUMMARIZE(Table1, Table1[ID],"_Value", [ASP per SQM] )

return
IF(HASONEVALUE(Table1[ID]), [ASP per SQM], SUMX(_table,[_Value]))

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xicai
Community Support
Community Support

Hi @fong ,

 

You may create new measure like DAX below to get correct total sum for the [ASP per SQM].

 

ASP per SQM_New=

var _table = SUMMARIZE(Table1, Table1[ID],"_Value", [ASP per SQM] )

return
IF(HASONEVALUE(Table1[ID]), [ASP per SQM], SUMX(_table,[_Value]))

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xicai ,

 

Thanks! That DAX formula was great for me to sum up another measure "Volume (SQM) = sum (Quantity) * average(width)*average (length) where the correct total is a simple sum of the column. That was really helpful and a great solution!

 

But for the ASP per sqm,  I have a problem because the formula does a sum of the column which doesn't make sense conceptually. The ASP per sqm is total $ sales by category divided by Volume (SQM) by category. The correct answer should be $30.98 but I got $240 in the new formula which is the total sum. Sorry if I wasn't clear.  Is there a way to amend this somehow ?

 

 

DataZoe
Employee
Employee

Hi @fong ,

 

Have you tried AVERAGEX? This will take the calculated values for each row and the average instead of recalculating it when it aggregates.

 

ASP per SQM =sales / sum(Quantity)*average(width)*average(length)

 

would then be:

 

ASP per SQM =AVERAGEX(TableName, sales / sum(Quantity)*average(width)*average(length))

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

I've tried that and all the values still look the same. 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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