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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
mhender
Regular Visitor

How to create a measure that will sum values of zero or greater?

I have created measure STOCK TO XFER using measures from different tables that subtracts to provide the difference.  Have also created measure XFER PLT using STOCK TO XFER and a measure from another table to summarize in pallet quantity.  Please see syntax below and sample data.

 

STOCK TO XFER = [INV ON HND]-[TLT Xwk DMND]

TLT Xwk DMND = sum(OPN_SOs[Xwk DMND])

INV ON HND = sum(PLT_DTL[On Hand Qty])
XFER PLT = DIVIDE([STOCK TO XFER],SUM(SKU_Detail[PLT BLD]))
 
INV ON HANDSTOCK TO XFERXFER PLT
1015-681-7.09
0-384-3.20
434525.21
3360315326.28
1651651.38
 
This works fine in line detail however does not make sense in the aggregate.  I need to undertand the sum of only postive values in STOCK TO XFER and XFER PLT. 
 
The above table totals in the below manner:
STOCK TO XFER = 2278
XFER PLT = 17.58
 
I need the total summation to result in this manner:
STOCK TO XFER = 3343
XFER PLT = 27.87
 
If any further data is need to help produce a result please ask.  Any help with this would be greatly appreciated.  
 
Thank you!
1 ACCEPTED SOLUTION
FreemanZ
Community Champion
Community Champion

hi @mhender ,

 

Not sure if i really get you, supposing you have a SKU_Detail[sku] column, try like:

STOCK TO XFER =

SUMX(

FILTER(

    ADDCOLUMNS(

        VALUES(SKU_Detail[sku]),

        "Diff",

        [INV ON HND]-[TLT Xwk DMND]

    ),

    [Diff]>0

),

[Diff]

)

View solution in original post

2 REPLIES 2
FreemanZ
Community Champion
Community Champion

hi @mhender ,

 

Not sure if i really get you, supposing you have a SKU_Detail[sku] column, try like:

STOCK TO XFER =

SUMX(

FILTER(

    ADDCOLUMNS(

        VALUES(SKU_Detail[sku]),

        "Diff",

        [INV ON HND]-[TLT Xwk DMND]

    ),

    [Diff]>0

),

[Diff]

)

Hi @FreemanZ , thank you for taking the time to read and offer a solution to this question! 

 

Disregard:

I have used attempted solution with exact syntax.  Receiving the below error on line 6:

"The following syntax error occurred during parsing: Invalid token, Line 1, Offset 95, [Diff)))."

Based on error thinking that "Diff" needs to be defined.  How would "Diff" be defined in this solution?

 

Syntax error on my part!!!  @FreemanZ this worked like a charm.  Can't thank you enough for the help with this.  Cheers!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.