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

Get minimum month with respect of minimum year

Any idea on how to get the minimum month with respect of minimum year?

Date.JPG

[New Table]:

Load

[Min_Year] &'|'& [Min_Month] as [%New_Data]

;

Load

    Min([Year]) as [Min_Year],

    Min([Month]) as [Min_Month]

I have no problem with the [Min_Year]. My goal to [Min_Month] is to return the min month with respect of min year. The result should be:

[%New_Data] = 2011 | May

The month is already in dual value  in mapping.

1 Solution

Accepted Solutions
sunny_talwar

May be combine the two before you find the Min..

Table:

LOAD ...,

     Date#(Month&'|'&Year, 'MMM|YYYY') as MonthYear

FROM ....;

NewTable:

LOAD Date(Min(MonthYear), 'MMM|YYYY') as [%New_Data]

Resident Table;

View solution in original post

9 Replies
sunny_talwar

How is Min Month for Min Year is December? You mean the Max Month for Min Year? Because Min Month for Min Year is January, isn't it?

Anonymous
Not applicable
Author

I have corrected my example above. The return value should be:

2011 | May

sunny_talwar

May be combine the two before you find the Min..

Table:

LOAD ...,

     Date#(Month&'|'&Year, 'MMM|YYYY') as MonthYear

FROM ....;

NewTable:

LOAD Date(Min(MonthYear), 'MMM|YYYY') as [%New_Data]

Resident Table;

sasiparupudi1
Master III
Master III

May be like below

[New Table]:

Load

[Min_Year] &'|'& [Min_Month] as [%New_Data]

;

Load

    Min([Year]) as [Min_Year],

    Month(Min(Date#([Year]&[Month],'YYYYMM'))) as [Min_Month]

Resident Table;

sunny_talwar

But why adding the additional complexity when it can be solved without it?

Anonymous
Not applicable
Author

Not exactly what I need right now. Comment below is my code.

sasiparupudi1
Master III
Master III

Yeah.. I dont know what I was thinking.. that solution does not make sense sunny!!

sunny_talwar

Sorry, I am not sure I understand your comment... What exactly are you trying to do? Can you elaborate on your requirement?

vishalarote
Partner - Creator II
Partner - Creator II

Maybe this will help you

t1:

LOAD * INLINE [

    Year, Month

    2011, May

    2013, February

    2013, March,

    2014, April

    2015, January

];

load

Date(Min(Date#(MonthYear,'YYYY|MMMM')),'YYYY|MMMM') as MonthYear;

t2:

load

Year&'|'&Month as MonthYear

Resident t1;

Drop table t1;

Capture17.PNG