Forum Discussion
ambi95
3 years agoHelper I
Excel formula to power query M code
Hi all, Im trying to convert the following formula in excel to M code : =CONCATENATE(H2, MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",( IFERROR(IF(FIND(MID(H2,1,1),"ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,...
ambi95
3 years agoHelper I
Hi ppm1 I modified your code to give me that lower case O in the middle, and it goes like this:
let
input = [columnname],
letters = {"A".."Z"},
concatvalues = {null, "A".."Z", "0".."5"},
splitinput = List.Split(Text.ToList(Text.Upper(input)), 5),
lettercheck = List.Transform(splitinput, (x)=> List.Transform(x, (y)=> Number.From(List.Contains(letters, y)))),
multipliers = {1, 2, 4, 8, 16},
listsums = List.Transform(lettercheck, (a)=> List.Sum(List.Transform({0..4}, (b)=> a{b} * multipliers{b}))),
listvalues = List.Transform(listsums, each concatvalues{_+1}),
result = input & Text.Combine(listvalues, "")
in
resultThanks for the help and hope I can come back to you with feedback and more help