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

Calculating YTD, YTD prior Year, month in prior Year by field YearMonth

Good day!

in load script i have field YearMonth in format YYYYMM (201507 - July'15)

I need to create in load script such flags:

YTD - must get period from beggining of max year till max YearMonth

YTDPriorYear - the same logic from YTD, but for prior year.

MTD - max YearMonth

MTDPriorYear - the same logic from MTD, but for prior year.

Please, help!

Thanks.

2 Replies
satishkurra
Specialist II
Specialist II

Please find below the script for loading YTD and LYTD in load script.

This is for M/D/YYYY format. Please use date conversion functions to achieve your desired format.

Hope it helps.

Sales:

LOAD * Inline [

TransactionDate,Sales

01/01/2014,100

02/01/2014,200

03/01/2014,900

01/01/2015,300

02/01/2015,400

03/01/2015,300

03/05/2015,400 ];

Temp:

LOAD

TransactionDate,

Year(TransactionDate) as Year,

-YearToDate(TransactionDate,0) as CYTD,

-YearToDate(TransactionDate,-1) as LYTD

Resident Sales;

Anonymous
Not applicable
Author

Thank you for your help.

But i have not any field with date. i have only yearmonth.