Forum Discussion
CONTAINSSTRING with multiple Values -> Cut String
- 4 years ago
lboldrino Try this with a few more CONTAINSSTRING's:
Column = SWITCH(TRUE(), CONTAINSSTRING([WorkDescription],"AX2012-"), VAR __Start = SEARCH("AX2012-",[WorkDescription]) VAR __Colon = SEARCH(":",[WorkDescription],__Start,LEN([WorkDescription])) VAR __Space = SEARCH(" ",[WorkDescription],__Start,LEN([WorkDescription])) RETURN MID([WorkDescription],__Start,MIN(__Colon, __Space) - __Start), CONTAINSSTRING([WorkDescription],"LUKART-"), VAR __Start = SEARCH("LUKART-",[WorkDescription]) VAR __Colon = SEARCH(":",[WorkDescription],__Start,LEN([WorkDescription])) VAR __Space = SEARCH(" ",[WorkDescription],__Start,LEN([WorkDescription])) RETURN MID([WorkDescription],__Start,MIN(__Colon, __Space) - __Start), BLANK() ) - 4 years ago
#"Added Conditional Column" = Table.AddColumn(#"Renamed Columns", "Jira", each if Text.Contains([WorkDescription], "AX2012-") then "AX2012-" else if Text.Contains([WorkDescription], "LUKSALE-") then "LUKSALE-" else if Text.Contains([WorkDescription], "LUKMC-") then "LUKMC-" else if Text.Contains([WorkDescription], "ISU-") then "ISU-" else if Text.Contains([WorkDescription], "BIZ-") then "BIZ-" else if Text.Contains([WorkDescription], "DWH-") then "DWH-" else if Text.Contains([WorkDescription], "AX40-") then "AX40-" else if Text.Contains([WorkDescription], "DWHOPT-") then "DWHOPT-" else if Text.Contains([WorkDescription], "PORTAL-") then "PORTAL-" else if Text.Contains([WorkDescription], "LUKSM-") then "LUKSM-" else if Text.Contains([WorkDescription], "LUKART-") then "LUKART-" else if Text.Contains([WorkDescription], "PAC-") then "PAC-" else null),
#"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "Code", each if [Jira] <> null then Text.Select(Text.BetweenDelimiters([WorkDescription],"-"," "),{"0".."9"}) else null),
#"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1", "Jira Booking", each if [Code] <> "" then [Jira] & [Code] else null)
lboldrino Well, one problem is that it looks like you don't have a space or a colon after those so it is grabbing the entire next word. Not sure what to do with that one unless those always have a set number of characters like AX2012-xxxx would be 11 characters but if you had AX2012-xxx then you would get one too many characters.
The second issue is that anywhere you have a LEN([Workdescription) make it
ok,
for exm.: for AX2012- i have only AX2012-xxxx. is it usefull?