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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
TimTeska
Frequent Visitor

Creating a new column using the contents from another cell.

Hello Experts,

I'm having trouble with something I think should be very straight forward. I am new to Power Query Editor and still learning DAX, M and I have no experience with JSON.

During a load and transform data in PBI Power Query Editor - I'm trying to create a new column called "Period" using some of the data from Column1 row 4 (or indexed row 3), and I only want the data to the left of the "," in that field. More detail below.

Background:

The Excel file I'm importing is a financial report, In Column1 (formatted as Text), the first 4 rows contain standard report data: the date stamp, the company name, the report, and then the period and type of report separated by a ",".

My objective:

I'm trying to create a dashboard that is linked to an Excel file Report. This dashboard needs to get updated every quarter or more. When I want to update the data in the dashboard, I want to just overwrite the old Excel report with the newest and refresh my dashboard, and let the PBI Power Query Editor run the steps I used to format the file in the final Query for the Dashboard.

The steps I used to create this new Column called "Period" using all data to the left of the comma in Column1 row 4.  In that field is "2023_Close_Q1, CSC0002_Region_JnJ GAAP" and I only want "2023_Close_Q1" to be reflected in the new Period Column See Screenshot.

My outcome:

I tried to insert a custom column, named it "Period" and for the formula I used "Text.BeforeDelimiter(Text.From([Column1]{3}), ",")" which retuns "Error" in the new Column "Period".

The returns says this : Which is strange because it's trying to use the data in Column1 row0 (see screenshot)

Expression.Error: We cannot convert the value "12/6/2023 5:32:31 PM" to type List.
Details:
Value=12/6/2023 5:32:31 PM
Type=[Type]

 

Any help from you pros would be so much appreciated.   Thank you.

 

Screenshots

2 Result of new Column2 Result of new ColumnDescriptionDescription1 Adding a new column1 Adding a new column

 

 

2 ACCEPTED SOLUTIONS
dufoq3
Super User
Super User

Hi @TimTeska,
you can't call value from another row directly (there are of course ways how to do it), but you can call line from previous step

Source (previous step):

dufoq3_0-1706637237648.png

Added custom column:

dufoq3_3-1706637730479.png


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

Anonymous
Not applicable

Hi @TimTeska ,

Please try:

Text.BeforeDelimiter(#"Changed Type"{3}[Column1],",")

vcgaomsft_0-1706679689930.png

Advanced editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTSN9M3MjAyVjA0tzI2UtJRQkGxOtFKjk7OCs75uQWJeZXYpINLk5zz84rzczJTEktSUxSCS3NzE4sqFYJSC/KLShQ0IHRmXromNt0gq+Odc/KLU+MDDXUUnIMNDAyM4oNS0zPz8+K98rwU3B0dAzA0xgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Period", each Text.BeforeDelimiter(#"Changed Type"{3}[Column1],","))
in
    #"Added Custom"

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @TimTeska ,

Please try:

Text.BeforeDelimiter(#"Changed Type"{3}[Column1],",")

vcgaomsft_0-1706679689930.png

Advanced editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTSN9M3MjAyVjA0tzI2UtJRQkGxOtFKjk7OCs75uQWJeZXYpINLk5zz84rzczJTEktSUxSCS3NzE4sqFYJSC/KLShQ0IHRmXromNt0gq+Odc/KLU+MDDXUUnIMNDAyM4oNS0zPz8+K98rwU3B0dAzA0xgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Period", each Text.BeforeDelimiter(#"Changed Type"{3}[Column1],","))
in
    #"Added Custom"

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

dufoq3
Super User
Super User

Hi @TimTeska,
you can't call value from another row directly (there are of course ways how to do it), but you can call line from previous step

Source (previous step):

dufoq3_0-1706637237648.png

Added custom column:

dufoq3_3-1706637730479.png


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Hi,

Thanks so much for the help.  I'm still getting an error though.

PBI Error.png

@TimTeska that's because you have to refer your prev. step which is #"Changed Type" and not Source. Source was prev. step in my case. See my post again.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.