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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
jashandeepkaur
New Member

add a new column in power query to combine year and quarter

jashandeepkaur_0-1692827614462.png

Hi everyone, i am trying to create a new column in PQ to combine year and quarter. 

i tried the below formula but it is giving me error. 

Year/Qtr = [Year] & "-" & [Quarter]

 

can you please help. 

 

jashandeepkaur_2-1692827833467.png

i got my year and quarter from the notified column. i used data tab to extract year, month and quarter. but now i cannot combine them. 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @jashandeepkaur 

You can add a custom column, then try the following code

Text.From([Year])&"-"&Text.From([Quarter])

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
mussaenda
Super User
Super User

Hi @jashandeepkaur ,

 

In Power Query, you cannot simply combine number and text data types.

Year and Quarter are number data type and "-" is text data type.

 

Here is one way of solving your issue. You will treat your numbers as text then you can concatenate them.

Year/Qtr = Number.ToText([Year]) & "-" & Number.ToText([Quarter])

 

JoeBarry
Solution Sage
Solution Sage

Hi @jashandeepkaur 

 

Along with the answer from @v-xinruzhu-msft you can use the Merge Columns feature in the Transformation Tab. 

 

First Highlight the Year Column then the Quarter Column and press the Merge Column button. You will be prompted to enter a separator and a column name

 

Thanks

Joe

 

If this post helps, then please Accept it as the solution 

v-xinruzhu-msft
Community Support
Community Support

Hi @jashandeepkaur 

You can add a custom column, then try the following code

Text.From([Year])&"-"&Text.From([Quarter])

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Top Solution Authors