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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculated Field using sum of one column but max of another

Hi all,

I am trying to figure out how to calculate how many weeks of supply of product I have based on my sales and the 'ending on hand' I have currently.

The problem comes with pivots always combining the data in the 'ending on hand'

I have data from several weeks being combined in the Data Model.

Example

past 3 weeks

Week 1

Item | Sales | EOH

A        |    3       |    7

B         |    2       |    4

 

Week 2

A    |  3  |  4 (Week 1 EOH - Week 2 Sales)

B    |   2 |  2

 

Formula: EOH (most current week) / (Sum of Sales/Count of weeks with sales (disctinct count))

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I was able to do it using CALCULATE

EOP =
CALCULATE (
    SUM ( [EOP Inv Qty] ),
    FILTER ( Weekly, [Fiscal Week Number] = MAXX ( Weekly, [Fiscal Week Number] ) )
)

View solution in original post

2 REPLIES 2
dax
Community Support
Community Support

Hi hrojas3,

I am not clear about your requirement, what did you mean "The problem comes with pivots always combining the data in the 'ending on hand'"? If possible, could you please explain it in details? In addition, if possible, could you please inform me your sample data and expecting output? Then I will help you more correctly.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

Anonymous
Not applicable

I was able to do it using CALCULATE

EOP =
CALCULATE (
    SUM ( [EOP Inv Qty] ),
    FILTER ( Weekly, [Fiscal Week Number] = MAXX ( Weekly, [Fiscal Week Number] ) )
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.