Forum Discussion

jeremyt's avatar
jeremyt
Frequent Visitor
7 months ago
Solved

Creating Measure with Filter against column that contains lists

I'm having trouble with a measure and have exhausted my limited knowledge. I have two tables: Site_Table, with a field labeled "County" which is a text field that represents the county of the site ...
  • maruthisp's avatar
    7 months ago

    Hi jeremyt ,

    Can you try to check attached pbix file to achieve the solution which you are looking for? 

    Please let me know if you have any further questions or need clarifications.

     

    If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated, thanks! 

     

    Best Regards, 

    Maruthi 

    LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/ 

    X            -  Maruthi Siva Prasad - (@MaruthiSP) / X



  • danextian's avatar
    7 months ago

    Hi jeremyt 

     

    I'm not exactly sure what your tables look like as you did not provide a sample data but assuming that in the service table, one row can have multiple taxonomies separated by a comma, you can virtually expand these and use the expansion in a filter.

    Countries Represented = 
    VAR ServiceTaxonomyExpanded =
        GENERATE (
            Service_Table,
            VAR _taxString = Service_Table[Taxonomies]
            VAR _taxCount =
                PATHLENGTH ( SUBSTITUTE ( _taxString, ",", "|" ) )
            RETURN
                ADDCOLUMNS (
                    GENERATESERIES ( 1, _taxCount ),
                    "Taxonomy",
                    TRIM (
                        PATHITEM (
                            SUBSTITUTE ( _taxString, ",", "|" ),
                            [Value],
                            TEXT
                        )
                    )
                )
        )
    VAR FilteredServices =
        FILTER (
            ServiceTaxonomyExpanded,
            [Taxonomy] IN VALUES ( Taxonomies[Taxonomies] )
        )
    RETURN
    COUNTROWS (
        DISTINCT (
            SELECTCOLUMNS (
                FilteredServices,
                "SiteID", Service_Table[SiteID]
            )
        )
    )
    
    

     

  • jeremyt's avatar
    jeremyt
    6 months ago

    Thanks, I needed to modify your formula a bit but after that it worked as needed!