0

assuming I have a table that has a list inside

+---------+--------------+
|   tag   |     val      |
+---------+--------------+
| [a,b,c] | 1            |
| [a,e]   | 2            |
| [f,g]   | 3            |
| [e,f]   | 4            |
+---------+--------------+

can I create a slicer that when selected will still filter the item inside the list of the tag column?

eg. i select on the filter "a" it will show 1 and 2. "e" will filter 2 and 4, "f" will filter 3 etc.

1 Answer 1

1

You may create a measure (returning 1/0) where you use PATHCONTAINS function. We need to remove square bracket and replace commas to pipe "|"; This measure you can put to filter pane in table/matrix visualization https://dax.guide/pathcontains/

ForFilter = 
var __selectedTag = SELECTEDVALUE(disconnected[tagList])
var __tags = SELECTEDVALUE('Table'[Tag])
var __path = SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(__tags,",","|"),"[",""),"]","")
return

IF(PATHCONTAINS(__path, __selectedTag),1,0)

enter image description here

EDIT: version for multiple selection

var __string = CONCATENATEX( VALUES(disconnected[tagList]), disconnected[tagList],"|")
var __tags = SELECTEDVALUE('Table'[Tag])
var __path = SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(__tags,",","|"),"[",""),"]","")
VAR Table0 =
    SELECTCOLUMNS(
    TOPN(1,
    SELECTCOLUMNS(
    ADDCOLUMNS (
        GENERATE (
            ROW ( "tag", __path ,"Text",__string ),
            VAR TokenCount =
                PATHLENGTH ([Text] )
            RETURN
                GENERATESERIES ( 1, TokenCount )
        ),
        "Word", PATHITEM ([Text], [Value] )
        
    ),
    "Word",IF(PATHCONTAINS([tag],[Word]),1,0),
    "Tag", [tag],
    "Values", [Value]
    ), [Word],DESC, [Values])
    ,"Bool", [Word])
    return

    Table0

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

This actually works when we select 1 item from the disconnected list of tags, when I tried multiple tags or select "all values" it does not work anymore
ok one last thing, will it work on bar charts?
As i know answer is yes (but i never need this kind of solution in my envoirment)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.