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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
wi11iamr
Advocate II
Advocate II

Sum future column values based on variable

I have a Vendor table where each Vendor has a different StockForwardCoverRatio.

 

The StockForwardCoverRatio represents the number of months for which I must sum the ForecastSales to see how much cover my Vendor's current stock level provides.

 

E.g. We are in November and VendorA has a StockForwardCoverRatio of 2.5. This means that I must sum the ForecastSales for the next 2.5 months. So I wish to sum the full amounts for December and January, and then half the amount of February.

 

The below code uses a static assumption of only 1.5 month's cover where I sum the December value, and then calculate half the sum of the January value.

 

Target Stock = 
    CALCULATE (
        [Remaining Forecast Cost],
        NEXTMONTH( DATESMTD ( 'Calendar'[Date] ) )
       
    )
    + DIVIDE(
        CALCULATE (
        [Remaining Forecast Cost],
        NEXTMONTH( DATEADD(DATESMTD ( 'Calendar'[Date] ),[Target Stock Cover Whole Months],MONTH))),2,0
    )

My trouble now is how to use the StockForwardCoverRatio value within such a measure that can, in the example of a 2.5 months StockForwardCoverRatio, sum the values from December and January, and then only half the value from February.

 

 

1 REPLY 1
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @wi11iamr

 

It seems you may use VAR function like below post. If it is not your case, sample data will be helpful to provide an accurate solution. 

https://community.powerbi.com/t5/Desktop/Auto-select-previous-months/td-p/81963

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.