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 a column that has a group of text and I want replace some key words within that group of text. For Example, I want take the value (Right;Sessions) and change to (Right,Session). I am not sure how to do that.
This is what I am hoping to achieve:
Keyphrases New Column
Right;Sessions Right;Session
No Sessions NO Session
Unplanned, Sessions Unplanned, Session
I try to use this switch statement to achieve my goal, but it did not work.
KeyPhrasesClean =
VAR SelectedName = SELECTEDVALUE([Keyphrases]) //This returns the selected value from original name in the table visual.
RETURN
SWITCH( SelectedName, //This evaluates true if the 2nd argument is ==, else it evaluates false and continues through the switch
"meetings", "meeting",
"sessions", "session",
"rooms", "room",
"SelectedName" //This simply returns the selected name if the name doesn't equal the values listed above
)
Regards,
Richard
Solved! Go to Solution.
If you just have a few replacements, then you can use nested SUBSTITUTE functions.
KeyPhrasesClean =
VAR SelectedName = CALCULATE ( SELECTEDVALUE ( [Keyphrases] ) )
RETURN
SUBSTITUTE (
SUBSTITUTE (
SUBSTITUTE (
SelectedName,
"Meetings", "Meeting"
),
"Sessions", "Session"
),
"Rooms", "Room"
)
I've tweaked it slightly so that it should work either as a measure or a calculated column.
If you just have a few replacements, then you can use nested SUBSTITUTE functions.
KeyPhrasesClean =
VAR SelectedName = CALCULATE ( SELECTEDVALUE ( [Keyphrases] ) )
RETURN
SUBSTITUTE (
SUBSTITUTE (
SUBSTITUTE (
SelectedName,
"Meetings", "Meeting"
),
"Sessions", "Session"
),
"Rooms", "Room"
)
Alexis, thanks for the quick reply. I am not sure if I am doing something wrong but it the solution you provided returns a blank row. Please note that I am trying to return the substituted value in a new column.
I've tweaked it slightly so that it should work either as a measure or a calculated column.
Thank you Alexis. It works to perfection now. I appreciate the quick, and outstanding response.
Best,
rpricien
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |