Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have this table with a field that contains data like this:
[9]
[9,19]
[19]
[4,9]
[9,17]
(and other values) Essentially it's square brackets [] with numbers in between them.
I need to find all the ones that have just 9. And I originally created the new column in Power BI like this:
Solved! Go to Solution.
Please try
COPC =
VAR String =
SUBSTITUTE ( SUBSTITUTE ( Admissions[TypeIds], "[", "" ), "]", "" )
VAR Items =
SUBSTITUTE ( String, ",", "|" )
VAR Length =
COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T =
GENERATESERIES ( 1, Length, 1 )
RETURN
IF (
"9" IN SELECTCOLUMNS ( T, "@Item", PATHITEM ( Items, [Value] ) ),
"Yes",
"No"
)
@Thomas_MedOne
I've made sample file to test the proposed solution. Please refer to attached
COPC =
VAR String =
SUBSTITUTE ( SUBSTITUTE ( Admissions[TypeIds], "[", "" ), "]", "" )
VAR Items =
SUBSTITUTE ( String, ",", "|" )
VAR Length =
COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T =
GENERATESERIES ( 1, Length, 1 )
RETURN
IF (
"9" IN SELECTCOLUMNS ( T, "@Item", PATHITEM ( Items, [Value] ) ),
"Yes",
"No"
)
@Thomas_MedOne
I've made sample file to test the proposed solution. Please refer to attached
COPC =
VAR String =
SUBSTITUTE ( SUBSTITUTE ( Admissions[TypeIds], "[", "" ), "]", "" )
VAR Items =
SUBSTITUTE ( String, ",", "|" )
VAR Length =
COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T =
GENERATESERIES ( 1, Length, 1 )
RETURN
IF (
"9" IN SELECTCOLUMNS ( T, "@Item", PATHITEM ( Items, [Value] ) ),
"Yes",
"No"
)
That is amazing, I would have never been able to figure that out. Thank you.
Sorry I was not clear. I need all of the 9's so It also has to match like [4,9] and [9,17] and even [9,19]
Please try
COPC =
VAR String =
SUBSTITUTE ( SUBSTITUTE ( Admissions[TypeIds], "[", "" ), "]", "" )
VAR Items =
SUBSTITUTE ( String, ",", "|" )
VAR Length =
COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T =
GENERATESERIES ( 1, Length, 1 )
RETURN
IF (
"9" IN SELECTCOLUMNS ( T, "@Item", PATHITEM ( Items, [Value] ) ),
"Yes",
"No"
)
If just 9 as you have mentioned, then please try
COPC = IF ( Admissions[TypeIds] = "[9]", "Yes", "No" )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
45 | |
25 | |
19 | |
16 | |
8 |
User | Count |
---|---|
70 | |
48 | |
45 | |
19 | |
16 |