Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
water-guy-5
Helper III
Helper III

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!

1 ACCEPTED SOLUTION
goncalogeraldes
Super User
Super User

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

View solution in original post

1 REPLY 1
goncalogeraldes
Super User
Super User

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

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.