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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
effertz12
Helper II
Helper II

Measure to calculate the sum of all the months previous without Neg Months included

Hi, I have a formula that is used in a matrix that calculates the my (Open Orders + Ships) - FC qty. 

it was Set up as an iterating view in SQL that can no longer be used. 

effertz12_1-1675365847508.png

the Formula for Open slots is (OpenOrder +Ships) - FCqty + IF(X>0, X, 0)

x is equal to the previous months open slots. 
is there a way to do this in a DAX formula? 


 

4 REPLIES 4
FreemanZ
Community Champion
Community Champion

hi @effertz12 

You can add a calculated column like:

Y =
[Open_Order_Qty] +[Ship_Qty] - [FC_Qty] + IF([X]>0, [X], 0)

my data set is individual orders and ships on one table and forecast for those items in a sepereate table. I cant calulate at the table level because we have different groupings that i need to be able to choose between which would mean i would need a table for every grouping we choose.

var Shipqty =  
            CALCULATE(
                    SUM(SHIPORDER[qty_shipped])
                        ,FILTER(SHIPORDER, SHIPORDER[ORMonth] <= DATES && SHIPORDER[DataType] = "MTD Ship" ))  

var Orderqty =  
            CALCULATE(
                    SUM(SHIPORDER[qty_ordered])
                        ,FILTER(SHIPORDER,SHIPORDER[ORMonth] <= DATES  && SHIPORDER[DataType] = "Open Order"))

var Holdqty  =
            CALCULATE(
                    SUM(HOLDS[qty_ordered])
                        ,FILTER(HOLDS, HOLDS[ORmonth] <= DATES && HOLDS[WFMP] = "Hold" ))

var FCqty  =
            CALCULATE(
                    SUM(FC[Units])
                        ,FILTER(FC, FC[FCDate] <= DATES  ))
return 
 Shipqty + Orderqty - FCqty
this is the formula im currently using. 

or you already have the Y column, but expecting something like:

Measure =
SUMX(
    FILTER(
        TableName,
        TableName[X]>0
    ),
     TableName[Y]
)
effertz12
Helper II
Helper II

my current formula evaluates OpenOrder+ships - FC for all the previous months up to the current month. Is there a way to not include months in which the OpenOrder+ships - FC formula goes negative? for example, in my picture above April would evaluate only the months of march and april but exclude febuary from the calc as it was negative in that month

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.