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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Andrew1
New Member

Does anyone know a good way to analyze model code options from a model string?

Does anyone know a good way to analyze model code options from strings?

 

I have a list model codes and I'm trying to find out what options are being ordered & analyze the data. I decided to find the code and create a column that says it exists (1) or doesn't exist (0) on

 that line.

An example of how I'm approaching this in DAX is below:

Option H5 =


SWITCH( 'Table'[Model String], "5000X",
IF(FIND("H5", 'Table'[Model String], 5, 0) = 0 , 0, 1) )

So this starts searching at character 5 and returns either a 1 or a 0 if the code is found.

 

 

Example TableExample Table

 

 

 

 

 

Does anyone know a better way to do this?

In the random case below we'll say that the type of product is a 5000X and everything after that is an "option" in the model string. These could be in any combination but I would assume they are unique codes. These options could be used across different types of products (e.g. 6000X, 7000X, etc...).

There are some cases where the product type has a different number of characters (e.g. 5000X, 5000XX) so if you know an even better way to include that in analyzing this data I would love to hear it.

I have other columns that have the product types listed (5000x, 6000X, 5000XX, etc...).

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Andrew1 ,

Please try to create column with below dax formula:

H5 = IF(CONTAINSSTRING([Model String],"H5"),1,0)
M6 = IF(CONTAINSSTRING([Model String],"M6"),1,0)
R7 = IF(CONTAINSSTRING([Model String],"R7"),1,0)
Z2 = IF(CONTAINSSTRING([Model String],"Z2"),1,0)

vbinbinyumsft_0-1675303121207.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Andrew1 ,

Please try to create column with below dax formula:

H5 = IF(CONTAINSSTRING([Model String],"H5"),1,0)
M6 = IF(CONTAINSSTRING([Model String],"M6"),1,0)
R7 = IF(CONTAINSSTRING([Model String],"R7"),1,0)
Z2 = IF(CONTAINSSTRING([Model String],"Z2"),1,0)

vbinbinyumsft_0-1675303121207.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

FreemanZ
Super User
Super User

hi @Andrew1 

Use CONTAINSSTRING instead of FIND, as defining the start position is not possible.

 

https://dax.guide/containsstring/

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.