Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Strooprover
Contributor
Contributor

Load formula for changing months and years

Hi,

I have a table with the following structure:

Article,
DemandYear,
DemandMonth,
Demand1

I want to link this table to a different table based on the article field.
In the end I only want to sum up the 'Demand1' values for the 3 most recent monts in my QV report.

Is it possible to write a variable formula in the load script (or later in the QV file) to get this summed up value no matter which month the current month/year is?

Much thanks in advance.

1 Solution

Accepted Solutions
MayilVahanan

Hi @Strooprover 

Try like below

Sum({<DemandDate={">=$(=MonthStart(Max(DemandDate),-2))<=$(=MonthEnd(Max(DemandDate)))"}>}Demand1)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

3 Replies
MayilVahanan

Hi @Strooprover 

Try like this

In Script,

MakeDate(DemandYear, DemandMonth,1) as DemandDate

In front end, try like this

Sum({<DemandDate = {">=$(=MonthStart(Max(DemandDate),-2)<=$(=MonthEnd(Max(DemandDate))"}>}Demand1)

Might be, it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Strooprover
Contributor
Contributor
Author

Hi @MayilVahanan ,


Thank you for your quick reply!

I've made the adjustments in the script.
The 'DemandDate' field is correctly made, but I seem to have problems with the frond end part.

When I make a regular sum of 'Demand1' I get a value, but with your sum I get a empty value.
In added a testfile as example.

Could you perhaps look why I don't get a correct sum?

Much thanks in advance!

MayilVahanan

Hi @Strooprover 

Try like below

Sum({<DemandDate={">=$(=MonthStart(Max(DemandDate),-2))<=$(=MonthEnd(Max(DemandDate)))"}>}Demand1)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.