Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
sfloberg
Partner - Contributor III
Partner - Contributor III

Last Month Values to Current Month

How can I take previous month (current year) of data and add it to the current month (current year)?

//Code for loading previous years of data
......

//Code below is current year january to last month (march as of now). When a new month has passed the data is added into the file. 
Concatenate(tmp_currency) 
LOAD Date(Date#(Datefield,'YYMMDD'),'YYYY-MM-DD') as Datefield,
Data
FROM ....
(biff, embedded labels, table is Sheet1);

Labels (1)
1 Solution

Accepted Solutions
rubenmarin

Hi, add one month to date can work?:

//Add previous month data to next month
Concatenate(tmp_currency) 
LOAD Date(AddMonths(Date#(Datefield,'YYMMDD'),1),'YYYY-MM-DD') as Datefield,
Data as DataLastMonth
FROM ....
(biff, embedded labels, table is Sheet1);

You can add a 'Where' clause to limit to one month and also to not add rows "after AddMonths(Today(), -1)" to not create future data.

You can also do a group by to keep Data and DataLastMonth in one row per Datefield.

 

View solution in original post

1 Reply
rubenmarin

Hi, add one month to date can work?:

//Add previous month data to next month
Concatenate(tmp_currency) 
LOAD Date(AddMonths(Date#(Datefield,'YYMMDD'),1),'YYYY-MM-DD') as Datefield,
Data as DataLastMonth
FROM ....
(biff, embedded labels, table is Sheet1);

You can add a 'Where' clause to limit to one month and also to not add rows "after AddMonths(Today(), -1)" to not create future data.

You can also do a group by to keep Data and DataLastMonth in one row per Datefield.