Forum Discussion
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%20CSV%20FILE%20V002.pbix?dl=0
Above link is my PBI FILE
Paul
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
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
6 Replies
- AlB
Community Champion
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
- AnonymousNot applicable
Hi Sir
Yes for this it is better not using M code. Thank you very much for sharing.
Paul
- AnonymousNot applicable
Hi Sir
I try to use your expression , i get error msg. Can you share with me where go wrong ?
- AlB
Community Champion
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