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

Variable value for previous month

Hello everybody!

I have to display numerical data for two months using text boxes. The value for the current month, and the value for the previous month as shown in the picture. I have a selection bar containing the various months as in attached picture.

I created a variable which shows the current month (August in this case) value, called Variable1.

Now, I want to get Variable1's values for the previous month (July in this case) . What code do i write?

The previous month in code:  =Monthname(max(MonthName)-1)  -  MonthName is the month variable from my table]


The code for the values i have shown under the current month in attached picture i.e August (95.4% & 93.5%) is: =$(Variable1)

[Summary: I want Variable1 value for =MonthName(max(MonthName)-1)]

Thanks a mill!

Regards,

Justin

4 Replies
nilesh_gangurde
Partner - Specialist
Partner - Specialist

Hiii

Use the below script to create the variable2.

 

date(AddMonths(max(PERIOD),-1))

Where PERIOD is the Fieldname which contains the date.

Regards,

Nilesh Gangurde

sreenivas
Creator III
Creator III

August:-vmonth=Month(now())

July:-vmonth-1

Not applicable
Author

Thank you Nilesh and Sreenivas for your quick reply!

But I would like to add:

Suppose I do not want to create a new variable and I just want use the old variable Variable1 (it shows the calculated monthly score for current month aka August)

Is there a way where i can write an equation of the form:

Equation:  call Variable 1 for condition Monthname(max(MonthName)-1)

Note: Monthname(max(MonthName)-1) condition must be used


So July value field would be =__________(equation)_____________________  and it would display Variable1's particular value for July..

I am not too well versed in code so you guys are being really helpful!

Thanks!



Justin

jonnathanr
Contributor III
Contributor III

Boa tarde amigo

tente a expressão

= MONTH (AddMonths (MAX (MonthName), - 1))