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

Writing a set analysis issue

I only want to count the test_id's when the interventiondate is later in time then the datetime.

The expression below I used doesn't work:

count(distinct {<interventiondate={">datetime"} >} test_id)

How do I write this?

Kind regards,

Katleen

1 Solution

Accepted Solutions
simenkg
Specialist
Specialist

Yes. This is because we are essentially doing TWO loads. The top one is a load FROM the bottom one. So since you change the name of the field interventiondate, it no longer exists in the top load.

change to:

load *,

  if(acties_totaal_interventiondate>=acties_totaal_datetime,1,0) as IntDateBiggerThanDateTimeFlag;

LOAD _id                          as test_id,

     _address_id                as addresses_id,

     action_category,

     actionname,

     status                          as acties_totaal_status,

     interventiondate               as acties_totaal_interventiondate,

     process_datetime           as acties_totaal_datetime

FROM

[..\2. Extraction to QVD layer\QVD_Ettenleur\Actions_69.qvd]

(qvd);

View solution in original post

11 Replies
manideep78
Partner - Specialist
Partner - Specialist

If you are fine with date format use this:  count({<interventiondate={">datetime"} >} distinct test_id)


else convert the datetime to the format you use and try this:


count({<interventiondate={">$(=Date(datetime))"} >} distinct test_id)

Not applicable
Author

Apparently I also need to count when the dates are the same.


I tried to adapt it like this, but it doesn't work:

count({<interventiondate={">=$(=Date(datetime))"} >} distinct test_id)


What did I do wrong this time?

er_mohit
Master II
Master II

Make sure date format of both is same

Not applicable
Author

interventiondate is a datefield.

datetime is a timestamp, but that should be solved with the date(datetime) function, no?

simenkg
Specialist
Specialist

use count({<interventiondate={">=$(=Date#(datetime,'DD.MM.YY hh:mm:ss'))"} >} distinct test_id)

replace 'DD.MM.YY hh:mm:ss' with the format you use for the timestamp.

simenkg
Specialist
Specialist

However if you want this to work as FOR each line: if interventiondate >= datetime count(distinct test_id) .

Then you have to use

sum(aggr(count({<interventiondate={">=$(=Date#(datetime,'DD.MM.YY hh:mm:ss'))"} >} distinct test_id),test_id))

Not applicable
Author

Still doesn't seem to work, I have attached a qvw witch some sample data.

Can you take a look at it?

Kind regards,

Katleen

er_mohit
Master II
Master II

See the attached file

simenkg
Specialist
Specialist

In your load script change it into the following:

Actions:

load *,

  if(interventiondate>=datetime,1,0) as IntDateBiggerThanDateTimeFlag;

LOAD _id as id,

     action_category,

     actionname,

     status,

     interventiondate,

     process_datetime as datetime

FROM

[Apps\2. Extraction to QVD layer\QVD_Ettenleur\Actions_69.qvd]

(qvd);

Then your expression becomes:
count({$<IntDateBiggerThanDateTimeFlag={1}>} distinct id)