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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
snowstar
Frequent Visitor

Filtering Out Skus that have S and their non-S conterparts

Hello all,

 

I have  been searching how to exclude from calculations all skus that have an S and and their non-S conterparts:

SKUSiteDateQty
12686A2024-10-31128
12686A2024-11-0680
12715A2024-10-2912
12715A2024-10-3110
12717A2024-10-313
12798B2024-10-299636
12798SB2024-10-319570
12799B2024-10-291992
12799B2024-10-315062
12799B2024-11-042500
12799SB2024-10-291826
12799SB2024-10-314976
12799SB2024-11-062500

 

I want the result to show this:

SKUSiteDateQty
12686A2024-10-31128
12686A2024-11-0680
12715A2024-10-2912
12715A2024-10-3110
12717A2024-10-313

 

The sku is from a productable and the qty is from a fact table.

 

I have been trying options and its not working.

I tried with filters and creating a measure.

Test =
CALCULATE (
    [Shipped Quantity],
    KEEPFILTERS( Products[sFlag] = 1
     
     )
 
)

Any hep is appreciated!

2 ACCEPTED SOLUTIONS
Gabry
Super User
Super User

Hey buddy @snowstar ,

 

try this

measure = sumx(
FILTER(
FILTER(Tabella, not Tabella[SKU] in

SELECTCOLUMNS(
ADDCOLUMNS(
SELECTCOLUMNS(FILTER(all(Tabella), RIGHT(Tabella[SKU],1)="S"), [SKU]), "NOs", LEFT(Tabella[SKU],5)),[NOs]) ) , not Tabella[SKU]  in  SELECTCOLUMNS(FILTER(all(Tabella), RIGHT(Tabella[SKU],1)="S"), Tabella[SKU]))
, Tabella[Qty])

 

and let me know 😉 

View solution in original post

vojtechsima
Super User
Super User

@snowstar hello,

here's similar approach as well:

Qty Sum Measure = 
var getS_SKU = 
CALCULATETABLE(
    VALUES('Table'[SKU]),
    CONTAINSSTRING('Table'[SKU], "S")
)
var findCounterParts =
    ADDCOLUMNS(getS_SKU, "nonS", LEFT('Table'[SKU], LEN('Table'[SKU])-1))

var uniteThem = UNION( getS_SKU, SELECTCOLUMNS(findCounterParts, [nonS]))

var _result =
CALCULATE(
    SUM('Table'[Qty]),
    KEEPFILTERS(NOT 'Table'[SKU] IN uniteThem)
)

return _result

 

vojtechsima_0-1731013131617.png

 

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1731139926780.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
snowstar
Frequent Visitor

Hello Resident Rocstar and Gabry!

Both answers work! 

Thank you very much!

vojtechsima
Super User
Super User

@snowstar hello,

here's similar approach as well:

Qty Sum Measure = 
var getS_SKU = 
CALCULATETABLE(
    VALUES('Table'[SKU]),
    CONTAINSSTRING('Table'[SKU], "S")
)
var findCounterParts =
    ADDCOLUMNS(getS_SKU, "nonS", LEFT('Table'[SKU], LEN('Table'[SKU])-1))

var uniteThem = UNION( getS_SKU, SELECTCOLUMNS(findCounterParts, [nonS]))

var _result =
CALCULATE(
    SUM('Table'[Qty]),
    KEEPFILTERS(NOT 'Table'[SKU] IN uniteThem)
)

return _result

 

vojtechsima_0-1731013131617.png

 

Gabry
Super User
Super User

Hey buddy @snowstar ,

 

try this

measure = sumx(
FILTER(
FILTER(Tabella, not Tabella[SKU] in

SELECTCOLUMNS(
ADDCOLUMNS(
SELECTCOLUMNS(FILTER(all(Tabella), RIGHT(Tabella[SKU],1)="S"), [SKU]), "NOs", LEFT(Tabella[SKU],5)),[NOs]) ) , not Tabella[SKU]  in  SELECTCOLUMNS(FILTER(all(Tabella), RIGHT(Tabella[SKU],1)="S"), Tabella[SKU]))
, Tabella[Qty])

 

and let me know 😉 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors