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 need to extract specific text from a column and output the result in a conditional column.
For example, I need to extract the word "Marketing" from the following sentence in the column, "This is for Marketing team to take action". Then, output "Marketing" in the newly created conditional column.
Looking forward to hearing from experts. Thank you
Solved! Go to Solution.
Hi @ShajiFiroz
Please download my sample PBIX with this data and code.
It's not clear if you are looking for only a single string "Marketing" or if you want to look for several different strings. Always best if you supply some sample data.
If you are looking for several strings you can create a Calculated Column like so
Column = SWITCH (
TRUE(),
CONTAINSSTRING ( 'Table'[TextCol], "Marketing" ), "Marketing",
CONTAINSSTRING ( 'Table'[TextCol], "Sales" ), "Sales",
CONTAINSSTRING ( 'Table'[TextCol], "HR" ), "HR",
CONTAINSSTRING ( 'Table'[TextCol], "Technology" ), "Technology",
CONTAINSSTRING ( 'Table'[TextCol], "Finance" ), "Finance",
""
)
resulting in this
Regards
Phil
Proud to be a Super User!
Hi @ShajiFiroz
Please download my sample PBIX with this data and code.
It's not clear if you are looking for only a single string "Marketing" or if you want to look for several different strings. Always best if you supply some sample data.
If you are looking for several strings you can create a Calculated Column like so
Column = SWITCH (
TRUE(),
CONTAINSSTRING ( 'Table'[TextCol], "Marketing" ), "Marketing",
CONTAINSSTRING ( 'Table'[TextCol], "Sales" ), "Sales",
CONTAINSSTRING ( 'Table'[TextCol], "HR" ), "HR",
CONTAINSSTRING ( 'Table'[TextCol], "Technology" ), "Technology",
CONTAINSSTRING ( 'Table'[TextCol], "Finance" ), "Finance",
""
)
resulting in this
Regards
Phil
Proud to be a Super User!
You can also use the CONTAINSSTRING command in Dax, for example,
Column =
IF (
CONTAINSSTRING ( 'Table'[Column1], "Marketing" ),"Marketing",
IF ( CONTAINSSTRING ( 'Table'[Column1], "Test" ), "Test",
"Null" )
)
Thanks @Anonymous
Power Query, Conditional column
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 |
---|---|
110 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
110 | |
91 | |
84 | |
66 |