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

hold all months less than current month in variable

Hi All, How do I define a variable which holds all months(separated by comma) less than current month  in a variable?

Cheers!

5 Replies
johnw
Champion III
Champion III

Assuming your months are defined as dates (like the first of the month, formatted to not show the day), then I believe this:

=concat({<Month={"=Month<monthstart(today())"}>} distinct Month,',',Month)

Anonymous
Not applicable
Author

Thanks John!

I tried this but my variable didn't return anything.. I think I am doing something wrong,

Here is my requirement:

If current month is Sept, my variable should return - Jan, Feb, Mar, Apr, May, Jun, Jul, Aug(i.e Months in MMM format separated by commas).

Thanks!

johnw
Champion III
Champion III

How are your months defined?

  1. date(monthstart(Date),'MMM') as Month
  2. month(Date) as Month
  3. 'Sep' as Month
  4. other?
Anonymous
Not applicable
Author

I read the current date from Today() function.

So I use Month(Today()) to get current month.

I want to use a variable which will store all MTD Months separated by commas(eg: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug).

Please let me know if you need anything further.

johnw
Champion III
Champion III

OK, if you're using month(today()) to get the current month, then I'm guessing you're using month(Date) as Month instead of monthstart(Date). In that case, just replace my monthstart() with month(). Hopefully this does the trick?

=concat({<Month={"=Month<month(today())"}>} distinct Month,', ',Month)