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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Searching Substring in VALUES

Hi

 

I have a Measure that finds all the items in my main table where a certal car model is selected.
Here's the DAX

 

Leads Qualified Consumer (1) Model = 
        IF(
            SELECTEDVALUE('Purchase Order'[Model])<>"All models";
            countrows(filter(Leads;Leads[Qualification]="Qualified" && Leads[Type - New 1]=TRUE() && Leads[Model Name] = SELECTEDVALUE('Purchase Order'[Model])))
;countrows(filter(Leads;Leads[Qualification]="Qualified" && Leads[Type - New 1]=TRUE())))

So this, if put in a pivot, gets all the rows in the LEADS table that are Qualified and Type 1 and IF not "All models" will also search for specific model.


This works, the next step is that sometimes "models" is more than one, so I created a table connected to my main Purchase Order with all the list of models for any specific row, and the new query is this

 

Leads Qualified Consumer (1) Model2 = 
        IF(
            SELECTEDVALUE('Purchase Order'[Model])<>"All models";
            countrows(filter(Leads;Leads[Qualification]="Qualified" && Leads[Type - New 1]=TRUE() && Leads[Model Name] in values('Purchase Order - Models'[Model]) ))


;countrows(filter(Leads;Leads[Qualification]="Qualified" && Leads[Type - New 1]=TRUE())))

So the trick here is getting the VALUES of the related table (which is filtered by the filter context) and do a "IN" this list.

Now the next step is that sometimes models are "substring": for example the model that I want to count might be "A Class" and the actual model in the leads table might be written as "A Class Business" and this one should count. 

So what I should do is not a "IN" but a "IN where substring". So I should extract the leftmost part of the models in the Leads table where the number of characters is the length of "A Class", and then do a "IN" this list. Keeping in mind that the list of models to be searched could be made of several cars of different length, for example "A Class" and "GLA"...

 

any suggestion?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi

 

thanks, I solved using SEARCH

 

sumX('Purchase Order - Models';countrows(filter(Leads;Leads[Qualification]="Qualified" && Leads[Type - New 1]=TRUE() && searcH('Purchase Order - Models'[Model];Leads[Model Name] ;1;-1)>0 )));

So this cycle through all the "models" and return true if it finds all values where the text is found

View solution in original post

2 REPLIES 2
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

Could you please share some sample file to have a test and post your desired result if possible?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi

 

thanks, I solved using SEARCH

 

sumX('Purchase Order - Models';countrows(filter(Leads;Leads[Qualification]="Qualified" && Leads[Type - New 1]=TRUE() && searcH('Purchase Order - Models'[Model];Leads[Model Name] ;1;-1)>0 )));

So this cycle through all the "models" and return true if it finds all values where the text is found

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.