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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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