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

Min(Variable)

I clearly have so much to learn!!!

I have a dataset which contains the field YearPeriod.

This field has records as follows: 2010 01, 2010 02, 2010 03, 2010 04 etc.

If I use YearPeriod as a dimension or expression, I get returns for the above.

However, if I make the expression Min(YearPeriod) I get 201001 - note there is no embedded space - and so this does not match any value in YearPeriod.

Why is this?

How do I return 2010 01?

Muchas Gracias

Dave

Message was edited by: davewright - typo

7 Replies
Not applicable
Author

Hi Dave,

There are many ways to address this. I would do something like below:

date#(text(replace(YearPeriod,' ','-')),'YYYY-MM') as YrPeriod

Cheers,

Shyam

Not applicable
Author

Hi Shyam,

Thanks for your suggestion, I am most grateful.

However, I'm not sure if it will do what I require.

(Sometimes I'm not sure just how much detail to include when asking.)

The point of Min(YearPeriod) equalling the minimum YearPeriod exactly, is that I want to use it to drive an indexing calculation.

But as there are no data indicated by the YearPeriod 201001 (no space) then I get only errors for the calculation.

If I understand what you have suggested, I will just end up with a Min(YearPeriod) equalling 2010-01, which still won't match any value in YearPeriod, won't I?

I guess I could create a new Year-Period variable by including the "-", but I am reluctant to do so - mainly because I am not comfortable with messing too much with my imported tables.

If you can shed any more light, I would be equally appreciative.

Not applicable
Author

Hi Dave,

Method I suggested earlier should work.

Once you create the field, then you could get your minimum and maximum variables using:

let vMin= date(min(YrPeriod),'YYYY MM');

let vMax= date(max(YrPeriod),'YYYY MM');

Cheers,

Shyam

Not applicable
Author

Thanks again, Shyam.

Just to be clear, would this be a script command?

Thanks.

Not applicable
Author

Hi Dave,

You can have the above in the script.

Another way for adding variables is by clicking on Settings on the toolbar --->Variable Overview and add the variables. Add variable name as vMin and in the expression define this as: =date(min(YrPeriod),'YYYY MM')

Similarly for vMax.

Hope this is suffice.

Cheers,

Shyam

Not applicable
Author

Plenty for me to be working with.

Thanks

8-)

rohit214
Creator III
Creator III

hI DAve

try this =replace(YearPeriod,'','-')

may it helps you

thanks

rohit