Forum Discussion

AnassEss's avatar
AnassEss
Helper I
2 years ago
Solved

Create a Simple Column with strings

Hi Once again,

 

I only want to create a simple Column with a string expression in every row NOT BASED ON ANYTHING just strings in a new column I tried with this:

Familia =
UNION (
    ROW ( "Familia", "hola" ),
    ROW ( "Familia", "adios" ),
    ROW ( "Familia", "hello" ),
    ROW ( "Familia", "bye" ),
    ROW ( "Familia", "Bonjour" ),
    ROW ( "Familia", "Ademain" )
) but I still get errors whenever I try a new approaching. We just want a column and fill the rows of the column as follows: row1: hola, row2: adios, row3: hello... looks simple and I still didnt find a way to do so.
 
Thanks in advance and kind regards
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi AnassEss ,

    Thanks Sahir_Maharaj  for the dax, it really helped solve the problem. The reason you were getting the error was because you had to add a New Table instead of adding a New column:

     

    FamiliaTable = 
    DATATABLE(
        "Familia", STRING, 
        {
            {"hola"},
            {"adios"},
            {"hello"}
        }
    )

     

    Final output:

     

    If you want to add a column to the back of the table, consider adding a Custom Column in Power Query:

     

    = Table.AddColumn(#"Changed Type", "Custom", each Table.AddColumn(#"Changed Type", "Custom", each if [Code] = 1 then "hola" else if [Code] = 2 then "adios" else if [Code] = 3 then "hello" else null, type text))

     

    Final output:

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

    If it does not help, please provide more details with your desired out put and pbix file without privacy information.

     

    Best Regards,

    Ada Wang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AnassEss ,

    Thanks Sahir_Maharaj  for the dax, it really helped solve the problem. The reason you were getting the error was because you had to add a New Table instead of adding a New column:

     

    FamiliaTable = 
    DATATABLE(
        "Familia", STRING, 
        {
            {"hola"},
            {"adios"},
            {"hello"}
        }
    )

     

    Final output:

     

    If you want to add a column to the back of the table, consider adding a Custom Column in Power Query:

     

    = Table.AddColumn(#"Changed Type", "Custom", each Table.AddColumn(#"Changed Type", "Custom", each if [Code] = 1 then "hola" else if [Code] = 2 then "adios" else if [Code] = 3 then "hello" else null, type text))

     

    Final output:

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

    If it does not help, please provide more details with your desired out put and pbix file without privacy information.

     

    Best Regards,

    Ada Wang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • Hello AnassEss,

     

    Can you please try this:

    FamiliaTable = 
    DATATABLE(
        "Familia", STRING, 
        {
            {"hola"},
            {"adios"},
            {"hello"},
            {"bye"},
            {"Bonjour"},
            {"Ademain"}
        }
    )
    
    • AnassEss's avatar
      AnassEss
      Helper I

      Hello,

       

      Thanks for the effort but I get: A multi-value table was provided where a single value was expected  as if the sintax was wrong.