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

Need a button to select last 3 months

How to create a button - when I click the button it should select last 3 months data.

1 Solution

Accepted Solutions
mrossoit
Creator II
Creator II

I suggest you to define a field in the same table of your date field as first day of the month:

MakeDate(my_year, my_month, 1) as YYYYMM01

or

MakeDate(year(my_date), month(my_date), 1) as YYYYMM01

Then define in variables view a variable that lists the last 3 months in date format:

varLast3Months = '(' &date(AddMonths(monthstart(today()),-3)) & '|' & date(AddMonths(monthstart(today()),-2)) & '|' & date(AddMonths(monthstart(today()),-1)) & ')'

Finally create your button with an action on selection in the field indicating your new data field (YYYYMM01) as field and =varLast3Months as search string.

Hope it helps.

Max

View solution in original post

8 Replies
mrossoit
Creator II
Creator II

I suggest you to define a field in the same table of your date field as first day of the month:

MakeDate(my_year, my_month, 1) as YYYYMM01

or

MakeDate(year(my_date), month(my_date), 1) as YYYYMM01

Then define in variables view a variable that lists the last 3 months in date format:

varLast3Months = '(' &date(AddMonths(monthstart(today()),-3)) & '|' & date(AddMonths(monthstart(today()),-2)) & '|' & date(AddMonths(monthstart(today()),-1)) & ')'

Finally create your button with an action on selection in the field indicating your new data field (YYYYMM01) as field and =varLast3Months as search string.

Hope it helps.

Max

terezagr
Partner - Creator III
Partner - Creator III

Anonymous
Not applicable
Author

Hi Rosso, Terrific result. It is working perfectly...

Anonymous
Not applicable
Author

Need a small favour. The below is to bring up the 1st date of month. How to change this to bring up for weeks?


MakeDate(year(my_date), month(my_date), 1) as YYYYMM01

mrossoit
Creator II
Creator II

I'm not sure to understand what result you want to reach. Could LunarweekStart() function help you in doining it?

Do you want to list all weeks of your month or, starting from my_date, you need to find the date when that week starts?

Anonymous
Not applicable
Author

I figured the solution... Thanks for your prompt reply.

leandroserrado
Partner - Contributor II
Partner - Contributor II

Great...

pgalvezt
Specialist
Specialist

Hi, Viyay I need the last Week too, Could you pls put your solution.

Appreciate that,

Thanks!