Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Filter for part of string value within column by column in another table

Good Afternoon,

I've been stuck on this DAX issue for days and would appreciate your help.

 

I have a table [STAR Active Clients] containing a list of services each client purchases from us. These services are separated by commas, as pictured below.

KMcDowell_0-1648660396187.png

I want to filter the table this service list is in by individual service (value within the string).
I have another table [STAR Active Jobs for Filter] only containing the list of services, as pictured below:

KMcDowell_1-1648660464228.png

I added a measure to [STAR Active Jobs for Filter] and placed this measure in a slicer. Problem is, the below DAX only filters for clients from [STAR Active Clients] that contain only the  1 single service rather than also including clients that contain the service within the string list of services. I need to slice [STAR Active Clients] for each service contained within the string. How can I change the below DAX to accomplish this? (I have 2 versions of the DAX calculation that provide the same, unwanted result.)

KMcDowell_2-1648660758544.png

KMcDowell_3-1648661001251.png

 
Thank you!
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@tamerj1 , I appreciate your help. I was able to find a solution by changing my relationships rather than using a measure or calculated column.

'STAR Active Clients' table has the list of services with ClientID being my key (unique value).

'STAR Active Jobs' has all jobs [Engagement Description] (in separate rows) associated with each ClientID, causing multiple values for each ClientID.

'STAR Active Jobs for Filter' is just the list of 78 job/engagement types. 
I set up the below relationships with 'Star Active Jobs' and 'STAR Active Clients' connected by ClientID. My visuals now display the correct clients when I select a service from the slicer.

KMcDowell_0-1648673449955.png

 

I both love and hate when the solution is much simpler than I try to make it!

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

@tamerj1 , I appreciate your help. I was able to find a solution by changing my relationships rather than using a measure or calculated column.

'STAR Active Clients' table has the list of services with ClientID being my key (unique value).

'STAR Active Jobs' has all jobs [Engagement Description] (in separate rows) associated with each ClientID, causing multiple values for each ClientID.

'STAR Active Jobs for Filter' is just the list of 78 job/engagement types. 
I set up the below relationships with 'Star Active Jobs' and 'STAR Active Clients' connected by ClientID. My visuals now display the correct clients when I select a service from the slicer.

KMcDowell_0-1648673449955.png

 

I both love and hate when the solution is much simpler than I try to make it!

tamerj1
Super User
Super User

@Anonymous 

I got the feeling that it should be the other way around but I wanted to make sure. However, I suppose that visual is based on the active clients table. If so, you may try to iterate over the active jobs table to compare the value of the current filter context with each value of the filter table

Star Services =
IF (
    SUMX (
        'Star Active Jobs',
        FIND (
            UPPER ( 'Star Active Jobs'[BKD Services] ),
            UPPER ( MAX ( 'Star Active Clients'[BKD Services] ) ),
            ,
            0
        )
    ) > 0,
    1,
    0
)
Anonymous
Not applicable

When I use this DAX, swapping the tables, I get the same result.

 

I was wondering if I need to utilize CONTAINS or something of the like to search the whole string of 'STAR Active Clients'[BKD Services] rather than only finding standalone values.

You mean CONTAINSTRING. I guess it might work but you may first try SEARCH instead of find. And no need to use UPPER

Anonymous
Not applicable

I'm not able to figure out passing columns into CONTAINSSTRING... Would my purpose be better served using a calculated column rather than a measure? I wasn't sure how dynamic a calculated column would be since I have 78 different services to filter by.

tamerj1
Super User
Super User

@Anonymous 

Or you're just placing the measure in the filter of the visual to filter only the rows that contain at least one of the values of the filter table?

tamerj1
Super User
Super User

Hi @Anonymous 

this a measure right? Not a calculated column?

what exactly this measure is supposed to count? How does your visual look like?

Anonymous
Not applicable

Yes, I'm using a measure rather than a calculated column.

I am mapping my [STAR Active Clients] in an Azure Map visual. I want to filter the client location plot points based on the services purchased. I'm using 'STAR Active Jobs for Filter'[BKD Services] in a slicer to select the clients with each individual service on [STAR Active Clients]. In the below picture, my slicer is only selecting clients that have only "AOS" as a service rather than also including those with "AOS" as 1 of many services in the list.

KMcDowell_0-1648665560869.png

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors