Forum Discussion
Creating Measure with Filter against column that contains lists
- 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
- 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] ) ) ) - 6 months ago
Thanks, I needed to modify your formula a bit but after that it worked as needed!
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]
)
)
)
- jeremyt6 months agoFrequent Visitor
Thanks, I needed to modify your formula a bit but after that it worked as needed!