Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Using a trim function

Hello, I have a set of data that looks like this, and want to convert this column into two seperate ones with "State" and "Status"

Alaska - Active                         
Texas - Active
Nebraska - Non Useable
Florida - Non Useable

I have already created a measure that cuts off any text past " -......" which returns me "Nebraska - Non Useable" --> "Nebraska", for example. So, my "State" column is good to go.

For my "Status" column, I have a calculated column that looks like this:


Project =
VAR _Position1 =
VALUE ( FIND ( "-", Table[State Status], 1, 0 ) )
VAR _Position2 =
IF (
_Position1 > 0,
FIND ( "-", Table[State Status], _Position1 + 1, 0 ),
0
)
RETURN
IF (
_Position1 > 0,
TRIM ( RIGHT ( Table[State Status], _Position2 + 11 ) )
)

What this does is return me only "Non Useable" (which makes sense given the "+11" which counts 11 characters from the right. What I need is some sort of additional piece of DAX that also solves for the text that needs "+6" for he values that contain "Active"
Thanks!

  • Hello there! Why not perform these transformation in the Power Query Editor with the help of the "Split column by" --> "Delimiter" --> and then select "-"?

1 Reply

  • Hello there! Why not perform these transformation in the Power Query Editor with the help of the "Split column by" --> "Delimiter" --> and then select "-"?