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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
knotpc
Advocate I
Advocate I

Power Query Editor Combine Multiple Columns to Create Single Date Column from bls.gov APIv2

Hello, 

 

I am importing bls.gov data for CPI Series https://api.bls.gov/publicAPI/v2/timeseries/data/CUUR0000SA0?registrationkey=your APIKey&startyear=2000&endyear=2019.

 

The data is parsing correctly but, I end up with useless dates when using a Date Table that has relationships with other economic data(API's) that contain real dates. Charting data in this format is useless as Power BI will SUM all the values for 2019, 2018 etc. See example data below from actual query. 

 

Orignal Data.PNG

To correct the issue, I would like to create a new Column named DATE that combines a new column called DAY, always 01 with Column1.period and Column1.year. To do this I modified the table to look like below, renaming columns and adding a column called day (each is the 1st). 

 

Modified Table.PNG

With the data in this format I now what to add a new column that combines the values in the above into a new DATE column. The end result should be for example 01/07/2019 for Row 1. My question is how to actually combine the three columns. I have tried ConcatenateX and Union both give me an error and the table will then not load. 

 

Any help on this one would be greatly appreciated as I have numerous tables that need modification to add a date so that they will play well with other API data sources that include complete dates. 

 

 

1 ACCEPTED SOLUTION

MFelix, 

 

I chose to perform the conversion in Query Editor to keep things clean. Your example worked perfectly once I changed the [Year] and [Month] to Whole Numbers. 

 

Thanks for your help. I totally missed the ability to do the conversion this way. 

View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @knotpc ,

 

You can do this in two different ways on the query editor or on DAX, in both manners no need to add the day column to your data since one of the date parameters is the day so you can place 1 on that part of the formula.

 

Query Editor

Add the following column:

Column with the Day column
#date([Year] , Number.FromText([Month]) , [Day])

Column wihtout the need for the day column
#date([Year] , Number.FromText([Month]) , 1)

The month part is convert to number since on your example you have it as text if all columns are number then just do the following

#date([Year] , [Month], [Day]) 

DAX

Add the following column:

Date = DATE('Table'[Year];'Table'[Mont];1)

Both should work as expected then just need to format as date.

 

Regards.

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix, 

 

I chose to perform the conversion in Query Editor to keep things clean. Your example worked perfectly once I changed the [Year] and [Month] to Whole Numbers. 

 

Thanks for your help. I totally missed the ability to do the conversion this way. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors