Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Convert numbers into text

Hi, I have a column with 4 different numbers, lets call them 1111, 2222, 3333, 4444. For a diagram, I want them to be named, e.g. for 1111, should be named AAAA, 2222 should be named BBBB etc.

 

What is the best way to do it? Is it with a convert()? Couldn't figure it out yet.

 

Thanks for any help!

  • Hi Anonymous ,

     

    What is the logic to give the names ?

    If you have it mapped in another table, you can just merge both tables and use this column.

7 Replies

  • camargos88's avatar
    camargos88
    Community Champion

    Hi Anonymous ,

     

    This is an Power Query solution using custom column:

     

    let
    _char = {"A".."Z"},
    _value = Number.FromText(Text.Start(Number.ToText([Column1]), 1)) - 1
    in Text.Repeat(_char{_value}, Text.Length(Text.From([Column1])))

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi camargos88 ,

       

      thanks for that solution. It unfirtunatley also didn't worked out. Power Bi shows "error" in every row of the column.

      As far as I understand your formula, I would say it is maybe not the right approach. But I'm not sure.

       

      To make it more clear:

      I have a column with four different numbers, that are in there.

       

      like

       

      Column1

      1111

      1111

      3333

      2222

      1111

      4444

      2222

       

      and I want to give every specific number of that four numbers, the right name.

       

      Like for example: 1111 is Steven, 2222 is Christoph, 3333 is Larry, 4444 is Magdalen

       

      So it should look like this:

       

      Column1          Column2

      1111                  Steven

      1111                  Steven

      3333                   Larry

      2222                  Christoph

       

      etc.

       

       

      • camargos88's avatar
        camargos88
        Community Champion

        Hi Anonymous ,

         

        What is the logic to give the names ?

        If you have it mapped in another table, you can just merge both tables and use this column.

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Anonymous ,

     

     

    Create a Calculated Column.


    Column = 
    SWITCH(
    TRUE(),
    'Table'[Column] = 1111 , "AAAA",

    'Table'[Column] = 2222 , "BBBB",

    'Table'[Column] = 3333 , "CCCC",

    'Table'[Column] = 4444 , "DDDD"

    )

     


    Regards,

    Harsh Nathani


    Appreciate with a Kudos!! (Click the Thumbs Up Button)

    Did I answer your question? Mark my post as a solution!

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous,

       

      thanks for that solution. It unfortunatley didn't worked out. Power Bi shows me the following message:

       

      DAX comparisons do not support comparisons between text and integer values. You can use the VALUE function or the FORMAT function to convert one of the values.

      But I think this is in general the right way to do it!

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        HI Anonymous ,

         

         

        What is the Data Type of 1111 ?? Is it Text or Integer.

         

        Pls check and let me know.

         

        Can you share a screen shot if your table.

         

        Regards,

        Harsh Nathani