Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

joeybird
Contributor II

count differently if different date

Hiya

I wish to on a chart, on after a certain date, count different conditions

I have the following expression

e.g

if(OrderDate < '01/01/2015', count({$<  DeliveryType = {"1"}CustomerID)) or

if(OrderDate > '01/01/2015', count({$<  DeliveryType = {"2"}, CustomerID))

I am having no joy

please advise / help

4 Replies
MVP
MVP

Re: count differently if different date

May be this:

Count({<OrderDate = {"$(='<' & MakeDate(2015, 1, 1))"}, DeliveryType = {1}> + <OrderDate = {"$(='>' & MakeDate(2015, 1, 1))"}, DeliveryType = {2}>}CustomerID)


Count({<OrderDate = {"$(='<' & Date(MakeDate(2015, 1, 1), 'YourDateFieldFormat'))"}, DeliveryType = {1}> + <OrderDate = {"$(='>' & MakeDate(2015, 1, 1), 'YourDateFieldFormat'))"}, DeliveryType = {2}>}CustomerID)


Note:
You have < (less than) and > (greater than), but not equal. I would expect data for OrderDate = 1/1/2015 so add = sign to one of the two expressions.

Re: count differently if different date

Hi Joanna, the syntax for set analisys is incomplete:

if(OrderDate < '01/01/2015', count({$<  DeliveryType = {"1"}>} CustomerID)) or

if(OrderDate > '01/01/2015', count({$<  DeliveryType = {"2"}>} CustomerID))

It can work depending of your dimension, if it's OrderDate it can work, if it's some field wich can have many OrderDate (like months o weeks) you'll need to add an aggregation funtion to OrderDate to pick only one of those values:

If(Max(OrderDate) ....

joeybird
Contributor II

Re: count differently if different date

Hiya

Sunny ...your version works best but only if I select  a OrderDate from the filter pane,

please advise / help

MVP
MVP

Re: count differently if different date

Would you be able to share a sample?

Community Browser