Skip to main content
Announcements
Jan 15, Trends 2025! Get expert guidance to thrive post-AI with After AI: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
robert99
Specialist III
Specialist III

sum( {$<Month = {$(#=Only(Month)-1)}>} Sales )

This works

sum( {$<Year = {$(#=Only(Year)-1)}>} Sales )

based on selecting the Year

but this doesn't

sum( {$<Month = {$(#=Only(Month)-1)}>} Sales )

Is it possible to get this to work ie if I select the month of June it selects May etc

Thanks

19 Replies
jvitantonio
Luminary Alumni
Luminary Alumni

Hi,

In your second expression, you need to change Year = by Month:

sum( {$<Month = {$(#=Only(Month)-1)}>} Sales )


Also, make sure that your month is a number.


This is not the best approach as when you select January the month will be 1 and 1-1 = 0.


Instead, you can create a sequential number for the  month in your script like this:


Load

...

YEAR*12+Month  as  Sequential_Month

From...


I hope this helps.


JV



datanibbler
Champion
Champion

Hi,

depending on how your months are formatted, try sth like this

>> sum({$<Month = {month(monthstart(today(), -1))}>}Sales) <<

( >> monthstart(today(), -1) << will give you the first day of the past month and you can go from there)

HTH

Best regards,

DataNibbler

MK_QSL
MVP
MVP

Try this...

sum( {$<Month = {$(#=Subfield('$(MonthNames)',';',Only(Month)-1))}>} Sales )

robert99
Specialist III
Specialist III
Author


Thansk for your reply

I actually had

sum( {$<Month = {$(#=Only(Month)-1)}>} Sales )

but it does't work

Ive tried num in various places but it still doesn't work

Ive been working on variosu combinations for hours but maybe I need a rest

like

sum( {$<Month = {$(#= num (Only(Month))-1)}>} Sales )

and

sum( {$<Month = {$(#= Only (num (Month)))-1)}>} Sales )but nothing works

QV can be frustrating at times (like most system though)

jvitantonio
Luminary Alumni
Luminary Alumni

Hi RJ,

Is your field Month actually a number?

Also, try to create the sequential field as mentioned. It will make things easier.

Thanks,

JV

robert99
Specialist III
Specialist III
Author

No. I,ve used Jan Feb Mar etc

I know this is the problem (using Jna rather than 1 etc) but how do I convert Jan to a number

And thank for your assistance

robert99
Specialist III
Specialist III
Author

MonthNames. Do I put in Jan,Feb, Mar as sub fields

jvitantonio
Luminary Alumni
Luminary Alumni

In that case you won't be able to subtract a number from a string. Please create a numeric number for this.

JV

MK_QSL
MVP
MVP

NO.. .just try it once