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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

First position with no-numeric character

Hi,

 

I have the following problem:

 

I have a string similar to the following"12345abc". So, I have to locate the first non-numeric character (in this case the letter A at position 6) and know how many characters I have before this, so that in case its length is less than 7, fill in with the character 0 ahead until it reaches a length 7 , with the following string left: "0012345".

 

Is there a function that can be done directly to me, or do I have to do it via M code?

 

With the SEARCH or FIND functions I have no way to do it directly.

 

Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi!

 

First of all thank you for your help, @Mariusz .

This solution is not valid. I need that if the code is 1234ABC, I will effectively return 0001234 and if the code is 1234ABC12 I will not return 0123412 as it currently does with the function you provided me.

Finally I managed to do it with IF functions nested inside each other. The function is as follows:

 

ArticuloOFPadreCorregido = IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];7)));LEFT(OFs[Articulo Proyecto];7);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];6)));"0"&LEFT(OFs[Articulo Proyecto];6);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];5)));"00"&LEFT(OFs[Articulo Proyecto];5);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];4)));"000"&LEFT(OFs[Articulo Proyecto];4);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];3)));"0000"&LEFT(OFs[Articulo Proyecto];3);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];2)));"00000"&LEFT(OFs[Articulo Proyecto];2);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];1)));"000000"&LEFT(OFs[Articulo Proyecto];1);OFs[Articulo Proyecto])))))))

Regards!

View solution in original post

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

Please try using the below function in query editor.

( #"Text to Transform" as text ) => let
    textToList = Text.ToList( #"Text to Transform" ),
    selectValuesFromList = 
        List.Select( 
            textToList, 
            each Value.Is( 
                Value.FromText( _ ), 
                type number 
            ) 
        ), 
    combineListToText = Text.PadStart( Text.Combine( selectValuesFromList ) , 7, "0" )
in
    combineListToText

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Anonymous
Not applicable

Hi!

 

First of all thank you for your help, @Mariusz .

This solution is not valid. I need that if the code is 1234ABC, I will effectively return 0001234 and if the code is 1234ABC12 I will not return 0123412 as it currently does with the function you provided me.

Finally I managed to do it with IF functions nested inside each other. The function is as follows:

 

ArticuloOFPadreCorregido = IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];7)));LEFT(OFs[Articulo Proyecto];7);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];6)));"0"&LEFT(OFs[Articulo Proyecto];6);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];5)));"00"&LEFT(OFs[Articulo Proyecto];5);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];4)));"000"&LEFT(OFs[Articulo Proyecto];4);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];3)));"0000"&LEFT(OFs[Articulo Proyecto];3);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];2)));"00000"&LEFT(OFs[Articulo Proyecto];2);
IF(NOT ISERROR(VALUE(LEFT(OFs[Articulo Proyecto];1)));"000000"&LEFT(OFs[Articulo Proyecto];1);OFs[Articulo Proyecto])))))))

Regards!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors