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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
priyav24
Creator II
Creator II

Calculation of sum of sales between range?

Hello Everybody,

                     I have a requirement where i need to to get sum(SalesNetPrice) between two month-year field ,

between Start_Year and End_Year.

i.e)Start_Year have values "Jan-2013" corresponding "End_Year"  have values "Dec-2013 ".

                       I need to calculate sum( SalesNetPrice) .with condition SalesDate_MonthYear in the range start_Year and End_yea

     Currently am tried the below expression which is not working

Expression :

=Sum({<SalesDate_MonthYear={">=$(StartYear) <=$(EndYear)"}>} SalesNetPrice)

Thanks in Advance,

Priya

11 Replies
Not applicable

try this:

Sum({<SalesDate_MonthYear={">=$(=date(StartYear)) <=$(=date(EndYear))"}>} SalesNetPrice)

salto
Specialist II
Specialist II

Hello,

sum ({<SalesDate_MonthYear= {"<=$(=date(EndYear))>=$(=date(StartYear)"} > } SalesNetPrice)

Maybe using the date() function may help in this case.

Regards.

priyav24
Creator II
Creator II
Author

No its not working since Start & End Year are not date field.

salto
Specialist II
Specialist II

Hi,

what type of fields are they?

Not applicable



try this then:


Sum({<SalesDate_MonthYear={">=$(=date(StartYear),'MMM-YYYY') <=$(=date(EndYear),'MMM-YYYY')"}>} SalesNetPrice)

amitarusi
Contributor III
Contributor III

which values do you have in SalesDate_MonthYear  ?

saumyashah90
Specialist
Specialist

StartYear and EndYear are variables...so change their definition

Date(min(Datefield),'MMM-YYYY') as StartYear

Date(max(Datefield),'MMM-YYYY') as EndYear

and then try that

priyav24
Creator II
Creator II
Author

The Values in SalesDate_MonthYear  are 'Jan-2004'...'Oct-2013'

amitarusi
Contributor III
Contributor III

so the values in startyear and endyear should be the in the same, if not you can change their format using makedate,