Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

set analysis expression -- using if sentence under 2 scenarios

Hello all, I have a question about using if statement and set analysis to calculate sales:

the calculation are under 2 scenarios, one is past_trips > 0 and isnull(cancellation_date) = 1; one is past_trips > 0 and isnull(cancellation_date) = 0

then we calculate the total with set values for certain variables, the expression is as follows:

if(past_trips > 0 and isnull(cancellation_date) = 1,

sum({<fiscal = {'$(vLastFY)'},

  [deposit_date] = {"<=$(=TimeStamp(vToday_Y-1))"}>} 1))

+

if(past_trips > 0 and isnull(cancellation_date) = 0,

sum({<fiscal = {'$(vLastFY)'},

  [deposit_date] = {"<=$(=TimeStamp(vToday_Y-1))"},

  [cancellation_date] = {">=$(=TimeStamp(vToday_Y-1))"}>} 1))

vToday_Y-1 is dynamic variable: =makedate(year(today())-1, month(today()), day(today()))


Is there anything wrong with this expression? Thanks so much for the help!


Xuan

1 Solution

Accepted Solutions
Not applicable
Author

I solved it,  better use set analysis

=count({<fiscal = {'$(vLastFY)'},

  [past_trips] -= {'0'},

  [deposit_date] = {"<=$(=TimeStamp(vToday_1Y_Ago))"},

  [cancellation_date] = {">=$(=TimeStamp(vToday_1Y_Ago))"}>} trip_no) +

count({<fiscal = {'$(vLastFY)'},

  [past_trips] -= {'0'},

  [deposit_date] = {"<=$(=TimeStamp(vToday_1Y_Ago))"},

  [status] = {'BK','WL','RQ'} >} trip_no)

View solution in original post

1 Reply
Not applicable
Author

I solved it,  better use set analysis

=count({<fiscal = {'$(vLastFY)'},

  [past_trips] -= {'0'},

  [deposit_date] = {"<=$(=TimeStamp(vToday_1Y_Ago))"},

  [cancellation_date] = {">=$(=TimeStamp(vToday_1Y_Ago))"}>} trip_no) +

count({<fiscal = {'$(vLastFY)'},

  [past_trips] -= {'0'},

  [deposit_date] = {"<=$(=TimeStamp(vToday_1Y_Ago))"},

  [status] = {'BK','WL','RQ'} >} trip_no)