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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
Resident Rockstar
Resident Rockstar

@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
Resident Rockstar
Resident Rockstar

@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
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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