Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet 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
Hello all,
I have been searching how to exclude from calculations all skus that have an S and and their non-S conterparts:
SKU | Site | Date | Qty |
12686 | A | 2024-10-31 | 128 |
12686 | A | 2024-11-06 | 80 |
12715 | A | 2024-10-29 | 12 |
12715 | A | 2024-10-31 | 10 |
12717 | A | 2024-10-31 | 3 |
12798 | B | 2024-10-29 | 9636 |
12798S | B | 2024-10-31 | 9570 |
12799 | B | 2024-10-29 | 1992 |
12799 | B | 2024-10-31 | 5062 |
12799 | B | 2024-11-04 | 2500 |
12799S | B | 2024-10-29 | 1826 |
12799S | B | 2024-10-31 | 4976 |
12799S | B | 2024-11-06 | 2500 |
I want the result to show this:
SKU | Site | Date | Qty |
12686 | A | 2024-10-31 | 128 |
12686 | A | 2024-11-06 | 80 |
12715 | A | 2024-10-29 | 12 |
12715 | A | 2024-10-31 | 10 |
12717 | A | 2024-10-31 | 3 |
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.
Any hep is appreciated!
Solved! Go to Solution.
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 😉
@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
Hello Resident Rocstar and Gabry!
Both answers work!
Thank you very much!
@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
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 😉
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
92 | |
83 | |
71 | |
49 |
User | Count |
---|---|
143 | |
120 | |
110 | |
59 | |
57 |