Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to recode Source.Name using M code ?

Hi All How to recode Value lable for SourceName :- SI_PM.CSV to PM SI_SD.CSV to SD Take the 4 and 5 charater. As i have many file. https://www.dropbox.com/s/7tk5tqkonpuama4/M%20CODE%20LOAD...
  • AlB's avatar
    5 years ago

    Hi Anonymous 

    If it's the 4th and 5th characters that you want, you can create a custom column with this code:

    =  Text.Middle( [Source.Name], 3, 2)

    Then you can delete the original Source.Name column if necessary and rename the newly created column

    Or you can use Table.TransformColumns( ) but the option above is probably easier

     

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

     

     

  • AlB's avatar
    AlB
    5 years ago

    Anonymous 

    You asked for a solution in M code, which is what I provided.  In the pic you seem to be trying to do it in DAX. If that is the case, you can create a calculated column with

    New col =
    MID(Table1[Source Name], 4, 2)
    
    

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers