The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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 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...).
Solved! Go to Solution.
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)
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.
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)
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.
User | Count |
---|---|
14 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
28 | |
18 | |
13 | |
7 | |
5 |