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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Concatenate two column and create a new column using Power Query

Hi Experts,

I am trying to concanate two column using power query. I am unable to get the output. I have "Month" and "Year" two separate columns in my calender table. I wanted to merge those two columns and get the output like, "2019-Jan"

 

this is my script for same:

 

= Table.AddColumn(#"Changed Type2", "YYYYMM", each [Fin Month] & [Fin Year])

 

I am getting "error" as my column value.

 

I even tried to create a new columns using power query script directly from the "advanced editor"

 

#"Inserted MonthYearLong" = Table.AddColumn(#"Inserted MonthYearLong", "Year Month", each [Month] & "-" & Text.From([Year])),

 

I am not sure whats the best way to get output like 2019-Jan!

 

Would appreciate your help.

 

Thanks in advance.

 

 

 

 

 

 

 

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

You cannot refer same step's name inside the expression.

Use the previous step name

 

#"Inserted MonthYearLong" = Table.AddColumn(#"Inserted MonthYearLong", "Year Month", each [Month] & "-" & Text.From([Year])),

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Hi Zubair Thanks for your response in relation to my above query. Now Ive referred previous step name. But still I am getting this error; Expression.Error: The column 'YYYYMM' of the table wasn't found. Details: YYYYMM #"Inserted First Characters1" = Table.AddColumn(#"Inserted First Characters", "DDD", each Text.Start([Day Name], 3), type text), #"Inserted MonthYearLong" = Table.AddColumn(#"Inserted First Characters1", "Year Month", each [Month] & "-" & Text.From([Year])), But I am getting error while I am trying to record the column details; #"Reordered Columns" = Table.ReorderColumns(#"Inserted First Characters1",{"Date", "Fin Year", "Month Name", "MMM", "YYYYMM", "Fin Month", "Day Name", "DDD", "Day of Week"}),

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors