Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Solved! Go to Solution.
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
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
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.
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.
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.