Search code examples
type-conversionkeypowerquerym

Cipher Key convert type problems (Power Query)


I'm trying to do a fonction who basically replace numbers by other things.

Here what I've done so far :

 (V2 as text) =>
 
 let
     CipherKey = 
       {
       {0,"µ"},
       {1,"@"},
       {2,"¤"},
       {3,"#"},
       {4,"|"},
       {5,"a"},
       {6,"£"},
       {7,"%"},
       {8,"§"},
       {9,"~"}
       }
 
 in
     Text.Combine(List.ReplaceMatchingItems(Text.ToList(V2),CipherKey))

The problem is when ever I'm adding this in another table as a new columns, I'm still getting everytime "Error : can't convert Number into text"

I've tried to add a "Number.ToText" on the last line, doesn't change a thing.

Do you guys have any clues ?


Solution

  • In the end I found the answer :

    (Num_V2 as number) =>
    
    let
        Num_V2 = Number.ToText(Num_V2)
    in
    
    let
        CipherKey = 
          {
          {"0","µ"},
          {"1","@"},
          {"2","¤"},
          {"3","#"},
          {"4","|"},
          {"5","a"},
          {"6","£"},
          {"7","%"},
          {"8","§"},
          {"9","~"}
          }
    
    in
    
        Text.Combine(List.ReplaceMatchingItems(Text.ToList(Num_V2), CipherKey))