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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
joshs444
Frequent Visitor

Formula Changes based on Context, incorrect values

I created a table to show the margin we are making per lb by item number):

 

joshs444_2-1674939708355.png

 

When I use a different category than Item, I get an incorrect value:

joshs444_3-1674939788487.png

 

 I would like the Modifier to average the items in that category and figure out the average "margin per pound" for all items in that category.

 

My formula for Margin per lb is:

Average Margin Per lb =
(DIVIDE([Average Margin],SUM('Item List'[Weight pe Case]),0)
)
Average Margin formula is:
 
Average Margin =
var UNIT = DIVIDE([Sum Margin],SUM('Sales by Item'[QTY]))
RETURN
AVERAGEX('Sales by Item', unit)

 

Any insights or help would be appreciated.

 

Thanks

 

 

1 ACCEPTED SOLUTION

Hi @joshs444 

not sure modifier is from which table therefore the most general formula would be 

Average Margin Per lb =
AVERAGEX (
VALUES ( 'Sales by Item'[Item Code] ),
CALCULATE (
DIVIDE (
DIVIDE ( [Sum Margin], SUM ( 'Sales by Item'[QTY] ) ),
SUM ( 'Item List'[Weight pe Case] ),
0
),
CROSSFILTER ( 'Sales by Item'[Item Code], 'Item Listm'[Item Code], BOTH )
)
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @joshs444 

What is the formula for [Sum Margin]?

Sum Margin = [Sum Sales] - [Sum Cost]
 
Sum Cost = sum('Sales by Item'[Extended Cost])
 
Sum Sales = sum('Sales by Item'[Extended Price])
 
Would it work if I was using SUMX?
 
Thanks!

Hi @joshs444 

not sure modifier is from which table therefore the most general formula would be 

Average Margin Per lb =
AVERAGEX (
VALUES ( 'Sales by Item'[Item Code] ),
CALCULATE (
DIVIDE (
DIVIDE ( [Sum Margin], SUM ( 'Sales by Item'[QTY] ) ),
SUM ( 'Item List'[Weight pe Case] ),
0
),
CROSSFILTER ( 'Sales by Item'[Item Code], 'Item Listm'[Item Code], BOTH )
)
)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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