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

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.

Reply
rosemilo
Frequent Visitor

Extracting String Using LEFT and SEARCH function

Hello,

 

I'm trying to extract the number before the colon (see example below) using DAX. 

rosemilo_0-1652293205883.png

 

Here are the steps I did:

1. To return the specified number of characters I want (it worked)

   c_Search Request Target Time = SEARCH(":", 'MyRequest_Consolidated'[Request Target Time],,LEN('MyRequest_Consolidated'[Request Target Time]))-1

2. To extract the number before the colon 

c_Request Target Time = LEFT('MyRequest_Consolidated'[Request Target Time], MyRequest_Consolidated[c_Search Request Target Time]) 
The second formula returns the error below:
rosemilo_1-1652293420343.png

 

Is there any other way to extract the number I need before the colon (:)? The data type of the column is "Text". Thank you!

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @rosemilo 

please try

 

c_Request Target Time =
IF (
    MyRequest_Consolidated[c_Search Request Target Time] > 0,
    LEFT (
        'MyRequest_Consolidated'[Request Target Time],
        MyRequest_Consolidated[c_Search Request Target Time]
    )
)

 

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @rosemilo 

please try

 

c_Request Target Time =
IF (
    MyRequest_Consolidated[c_Search Request Target Time] > 0,
    LEFT (
        'MyRequest_Consolidated'[Request Target Time],
        MyRequest_Consolidated[c_Search Request Target Time]
    )
)

 

Thank you! It worked! 😊

tamerj1
Super User
Super User

@rosemilo 

Can you please provide sample data?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors