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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
userid128223
Creator
Creator

set analysis with if statement

Below statement gives me current total sales of all the companies despite any selection.

What I want to do is:

Give me total sales of currently selected company, excluding other companies, excluding any time line selection.

=if(PurchaseDate > AddMonths(today(),-12)   this is true then  sum(totalsales) - (total cost)   excluding time period selection.

How can i do that.

Thx

1 Solution

Accepted Solutions
Not applicable

Hi,

Suppose the date format for PurchaseDate is DD-MM-YYYY then

Create a variable vDate= date(AddMonths(today(),-12),'DD-MM-YYYY')

=sum( {<PurchaseDate ={">=$(vDate)",Year,Month}>} totalsales) -

sum( {<PurchaseDate ={">=$(vDate)",Year,Month}>} total cost)

Note- to exclude time period selections bypass Year and Month as i did in the expression.

Regards

Apurva

View solution in original post

3 Replies
Not applicable

should be something like this...

sum(  {$<PurchaseDate ={'>$(=AddMonths(today(),-12) '}>} totalsales) -
sum({$<PurchaseDate ={'>$(=AddMonths(today(),-12) '}>} total cost)

if you are dealing with period, it's better to build a calendar master data, says from past 2 year until next 50 years.

with columns like MMM YYYY, Quarter, row numbering, YYYYMM in digit (simply YYYY*100 + MM)

row numbering will be very very useful and handly when u want to do past 12 month until prev month... etc....

userid128223
Creator
Creator
Author

your suggestion did not work.

Any other help.

Not applicable

Hi,

Suppose the date format for PurchaseDate is DD-MM-YYYY then

Create a variable vDate= date(AddMonths(today(),-12),'DD-MM-YYYY')

=sum( {<PurchaseDate ={">=$(vDate)",Year,Month}>} totalsales) -

sum( {<PurchaseDate ={">=$(vDate)",Year,Month}>} total cost)

Note- to exclude time period selections bypass Year and Month as i did in the expression.

Regards

Apurva