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.
Hello to all,
The syntax to represent a list is list1 = {"A", "B","C"}. Is there a way to represent a column in hardcoded way like a list?
I have a table with 3 rows and I want to add a custom column with the values Yellow, Blue and White. I'm doing like below
= Table.AddColumn(#"Added Custom", "Custom", each Table.FromList({"Yellow","Blue", "White"}))
But this code adds the column "Custom" with each element containing a table.
How can I create the new column with row1 = "Yellow", row2="Blue", row3="White"?
Thanks for any help
Solved! Go to Solution.
Hi @cgkas ,
Can this meet your requirements?
Attach the complete codes:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKsovN1SK1QEzjGAMYxjDBMYwhTHMlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Mod", each Number.Mod([Index],3)),
#"Added Conditional Column" = Table.AddColumn(#"Added Custom", "Color", each if [Mod] = 1 then "Yellow" else if [Mod] = 2 then "Blue" else if [Mod] = 0 then "White" else null),
#"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"Index", "Mod"})
in
#"Removed Columns"
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @cgkas ,
Can this meet your requirements?
Attach the complete codes:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKsovN1SK1QEzjGAMYxjDBMYwhTHMlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Mod", each Number.Mod([Index],3)),
#"Added Conditional Column" = Table.AddColumn(#"Added Custom", "Color", each if [Mod] = 1 then "Yellow" else if [Mod] = 2 then "Blue" else if [Mod] = 0 then "White" else null),
#"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"Index", "Mod"})
in
#"Removed Columns"
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Have you considered using "Merge Columns". First create a small table with one column with the values you want in each row. Then merge it with the table you want to add the column to.
Help when you know. Ask when you don't!
Hello @kentyler ,
I've tried like you suggested, but I think something is missing.
I have the following steps:
First step: Source (This is the table with several columns for which I want to add the new column)
Second step: SmallTable (The small table you suggested)
Third step: MergeColumn
The merge column step has this command, but I get error.
= Table.AddColumn(Source, "Merged", each Text.Combine({[NewColHearder]}, ""), type text)
May you show please how should be used the merge in this case.
Thanks
Power BI is not really a data entry program. You cannot merge tables unless they each have a column that can be used to relate them to each other.
You are probably using a simplified example.
Why are you trying to do this.
Why not just add the new column in your data source.
If the colors you want to add is related to the other columns, for example, each color represents a city, then you need a custom column with some DAX code in it to pick the color for the row.
If you want to to a screen share to explore this, send me your email ( ken@8thfold.com ). I suspect you are trying to use power bi to do something it cannot do and that you will have to do in your data source.
Help when you know. Ask when you don't!
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
63 | |
53 | |
39 | |
25 |
User | Count |
---|---|
85 | |
57 | |
45 | |
43 | |
38 |