Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
slondono
Partner - Creator II
Partner - Creator II

Cumulative sum (Set Analysis)

Hi everybody,

I have a problem with a set analysis.

I need to sum values depends on which month is selected. For example

I have two fields: Final Cost and PPTO

For January: Sum(Final Cost) / Sum({<Month={feb,mar,apr}>}PPTO) // but i need this dynamic

The rule is: Sum of Final Cost of the current month / Sum of PPTO of the next three months

Hope you can help me

3 Replies
aarkay29
Specialist
Specialist

Something Like This

Sum({<DateField={">=$(=MonthStart(Max(today())))"}>}Final Cost) / Sum({<DateField={">$(=MonthEnd(Max(today())))<=$(MonthEnd(AddMonths(Max(today()),4)))"}>}PPTO)

sunny_talwar
MVP
MVP

Next three months? Are you assuming that  Jan is selected?

MK9885
Master II
Master II

Are you using Master Calendar? I believe that will be easier.

//This will be next three month excluding current month.

if(InQuarterToDate(TempDate, today(),-3), 1, 0) as NextQTRFlag,

if(InMonthToDate(TempDate, today(),0), 1, 0) as CurMonthFlag,

Insert above syntax in your master script if you have one.

And

sum({<CurMonthFlag={1}>}[Final Cost])/sum({<NextQTRFlag={1}>}[PPTO])

This should work I guess.