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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.