Powerbi: remove part of the string value in column and put it to another table

57 Views Asked by At

I have values in powerbi column with prefix e.g. Title: some title. I want to put this column to another table using dax, but without prefix "Title: " so it should be "some title".

In source table values can contain this prefix but there could be some values that do not have it.

Old column new column
Title: some title some title
Title: sky sky
Apple Apple
Title: xxx Title xxx Title
2

There are 2 best solutions below

0
Amira Bedhiafi On BEST ANSWER

You can also create a calculated table :

Attempt = 
SELECTCOLUMNS(
    TitleTable,
    "Old Column", [Old Column],  
    "New Column",                
    IF(
        FIND("Title: ", [Old Column], 1, LEN([Old Column]) + 1) = 1,
        TRIM(MID([Old Column], LEN("Title: ") + 1, LEN([Old Column]))),
        [Old Column]
    )
)

enter image description here

2
davidebacci On

You should do this in PQ but here is a DAX solution:

Column = 
VAR x = SEARCH("Title: ", 'Table'[Old column], , 0)
RETURN IF(x>0,  MID('Table'[Old column], 8, LEN('Table'[Old column])), 'Table'[Old column])

enter image description here