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! Learn more

Reply
sudden1sam
New Member

FInd ALL slicer selections within a string field

My primary fact table has a field (Products) that contains one or many products separated by semicolons. I have a second table with the unique product names, from which I've created a slicer. I would like to use the slicer to select records from the primary fact table where ALL of the selected slicer values appear in the Products field. In the example below, where Blue and Brown are selected in the slicer, I would like the primary table to filter to only Product 4341, the only row where BOTH Blue and Brown appear in Products. 

 

sudden1sam_0-1735225406218.png

 

I am aware that I could use Data Transformation to break the rows in the primary data table, but don't want to. I am ultimately trying to provide users with a filtered table with records that meet the selected criteria, and would like to count those records.

1 ACCEPTED SOLUTION
olgad
Super User
Super User

Ensure there’s no direct relationship between the Products column in the fact table and the slicer table. 

Try this:

FilteredRowCount =
VAR SelectedProducts = VALUES(SlicerTable[ProductName]) -- Get selected slicer values
VAR FactTableRows =
ADDCOLUMNS(
'FactTable',
"@MatchCount",
COUNTROWS(
FILTER(
SelectedProducts,
SEARCH(";" & [ProductName] & ";", ";" & FactTable[Products] & ";", 1, 0) > 0
)
)
)
VAR FilteredRows =
FILTER(
FactTableRows,
COUNTROWS(SelectedProducts) = [@MatchCount]
)
RETURN
COUNTROWS(FilteredRows)


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

View solution in original post

3 REPLIES 3
sudden1sam
New Member

Thank you, Olgad. For others who might read this topic, I had to fuss a little with the arguments to SEARCH. Specifically, I eliminated the concatentations (all of the "&"s) so that my SEARCH looked more like the following:
 

SEARCH (
       ( [SlicerSelection] ) ,
       ( [FactTableField] ),
       1, ) > 0
 
 
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1735235946434.png

 

PATH function (DAX) - DAX | Microsoft Learn

 

PATHITEM function (DAX) - DAX | Microsoft Learn

 

selected order id list = 
VAR _n =
    COUNTROWS ( ALL ( products ) )
VAR _filtercount =
    COUNTROWS ( products )
VAR _series =
    GENERATESERIES ( 1, _n, 1 )
VAR _path =
    ADDCOLUMNS ( 'order', "@path", SUBSTITUTE ( 'order'[products], "; ", "|" ) )
VAR _pathiteminrows =
    GENERATE (
        _series,
        VAR _number = [Value]
        RETURN
            ADDCOLUMNS ( _path, "@pathitem", PATHITEM ( [@path], _number ) )
    )
VAR _t =
    FILTER (
        SUMMARIZE ( _pathiteminrows, 'order'[order_id], [@pathitem] ),
        [@pathitem] <> BLANK ()
    )
VAR _productlist =
    VALUES ( products[products] )
VAR _selectedorderidlist =
    FILTER (
        ADDCOLUMNS (
            _t,
            "@filtercount",
                COUNTROWS (
                    FILTER (
                        _t,
                        EARLIER ( [order_id] ) = 'order'[order_id]
                            && [@pathitem] IN _productlist
                    )
                )
        ),
        [@filtercount] = _filtercount
    )
RETURN
    IF (
        ISFILTERED ( products[products] ),
        CONCATENATEX (
            SUMMARIZE ( _selectedorderidlist, 'order'[order_id] ),
            'order'[order_id],
            ", "
        )
    )

 

 

count selected order id list = 
VAR _n =
    COUNTROWS ( ALL ( products ) )
VAR _filtercount =
    COUNTROWS ( products )
VAR _series =
    GENERATESERIES ( 1, _n, 1 )
VAR _path =
    ADDCOLUMNS ( 'order', "@path", SUBSTITUTE ( 'order'[products], "; ", "|" ) )
VAR _pathiteminrows =
    GENERATE (
        _series,
        VAR _number = [Value]
        RETURN
            ADDCOLUMNS ( _path, "@pathitem", PATHITEM ( [@path], _number ) )
    )
VAR _t =
    FILTER (
        SUMMARIZE ( _pathiteminrows, 'order'[order_id], [@pathitem] ),
        [@pathitem] <> BLANK ()
    )
VAR _productlist =
    VALUES ( products[products] )
VAR _selectedorderidlist =
    FILTER (
        ADDCOLUMNS (
            _t,
            "@filtercount",
                COUNTROWS (
                    FILTER (
                        _t,
                        EARLIER ( [order_id] ) = 'order'[order_id]
                            && [@pathitem] IN _productlist
                    )
                )
        ),
        [@filtercount] = _filtercount
    )
RETURN
    IF (
        ISFILTERED ( products[products] ),
        COUNTROWS ( SUMMARIZE ( _selectedorderidlist, 'order'[order_id] ) )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
olgad
Super User
Super User

Ensure there’s no direct relationship between the Products column in the fact table and the slicer table. 

Try this:

FilteredRowCount =
VAR SelectedProducts = VALUES(SlicerTable[ProductName]) -- Get selected slicer values
VAR FactTableRows =
ADDCOLUMNS(
'FactTable',
"@MatchCount",
COUNTROWS(
FILTER(
SelectedProducts,
SEARCH(";" & [ProductName] & ";", ";" & FactTable[Products] & ";", 1, 0) > 0
)
)
)
VAR FilteredRows =
FILTER(
FactTableRows,
COUNTROWS(SelectedProducts) = [@MatchCount]
)
RETURN
COUNTROWS(FilteredRows)


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

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