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

Month to date (MTD) in loading script

Hey guys. I have a question.

I would like to create a table in which I want to have values for Month to Date. I know it can be achieved , by using expresions , but it would be better if I will have this table created.

Can you please help me with some hints?

Thank you,

Razvan

7 Replies
tresesco
MVP
MVP

Have a look here: Year-over-Year Comparisons

razvan_brais
Creator III
Creator III
Author

This is achieved with expressions . But I would like to do this in loading script.

tresesco
MVP
MVP

You mean, the value itself has to be calculated in the script? And you don't even want to use flag in set analysis expression? If so, I guess that would not be very good approach to follow since that makes your values literally static.

rahulpawarb
Specialist III
Specialist III

May be this:

SummaryTable:

LOAD Year([Date]) AS CYYear,

     Month([Date]) AS CYMonth,

     Sum(Sales) AS Amount

Resident Orders

Group By Year([Date]),

         Month([Date]);

Regards!

Rahul

razvan_brais
Creator III
Creator III
Author

This is good , if I want to have sa static value for MTD.

Basically , I want to calculate for each day the value MTD.

tresesco
MVP
MVP

May be the way is: The As-Of Table

tresesco
MVP
MVP

Check it here, I have implemented MTD in the script with a sample data set.

Tran:

Load

       *,

       month(Date) as Month,

       year(Date) as Year;

Load

       RecNo() as Sales,

       date(Addyears(today(),-2)+RecNo()) as Date

AutoGenerate 365*2;

NoConcatenate

AsOfCal:

load

       *

Resident Tran;

JOIN (AsOfCal)

Load

       Date as AsOfDate

Resident Tran;

Drop Table Tran;


LEFT JOIN

Load

       AsOfDate as Date,

       Sum(If(InMonthToDate(Date,AsOfDate,0),Sales)) as MTDSales

resident AsOfCal  Group By AsOfDate;



PFA