Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
SteveApa
Frequent Visitor

Create a string Column in Advanced Editor

Hi All...

How do I create a new column (named Type) in advanced editor and set it to a string value?  

let
Source = Sql.Database("XXXXXX", "YYY", [Query="
select
[Proj] as ""Proj#"",

null as ""Type"" -- this works

8 as ""Type"" - this works
""special"" as ""Type"" -- this does not.  How to do this?
from
[mytable] 
"])
in
Source

 

1 ACCEPTED SOLUTION
SteveApa
Frequent Visitor

Sorry... But you are all incorrect.  I had a different typo.  It does work to assign a "string" to a new column in a select statemement:

let
    Source = Sql.Database("xxxx", "yyy", [Query="
        select
              'GDC' as ""Type""
        from
            [table1] 

        union
        select
            'bill' as [Type]
        from
            [table2] bill
      "])
in
    Source

 

 

View solution in original post

3 REPLIES 3
SteveApa
Frequent Visitor

Sorry... But you are all incorrect.  I had a different typo.  It does work to assign a "string" to a new column in a select statemement:

let
    Source = Sql.Database("xxxx", "yyy", [Query="
        select
              'GDC' as ""Type""
        from
            [table1] 

        union
        select
            'bill' as [Type]
        from
            [table2] bill
      "])
in
    Source

 

 

v-ssriganesh
Community Support
Community Support

Hello @SteveApa,
Thank you for reaching out to the Microsoft Fabric Community forum.

Also thanks you, @Cookistador for the great insight. string values cannot be directly assigned in the SQL query within Power Query. Instead, you’ll need to add the text column within Power Query after retrieving the data.

  • NULL and numeric values work in SQL because they are less ambiguous.
  • String values require explicit handling within Power Query.
  • The best approach is to add the new column after loading the data into Power Query.


If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.

Cookistador
Super User
Super User

If I remember well, you cannot

You have to add the text column with 

AddedTypeColumn = Table.AddColumn(Source, "Type", each "special", type text)


NULL and numeric values are often handled seamlessly because they are less ambiguous.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors