Skip to main content
Announcements
YOUR OPINION MATTERS! Please take the Qlik Experience survey you received via email. Survey ends June 14.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Several tests on same field in set analysis

Hi!

I have this set analysis that works fine and select records with FASTTRACK_SENT_NUM within the last 12 months:

count ({$<FASTTRACK_SENT_NUM={'>$(=NUM(AddMonths(makedate($(vYear),$(vMonth),1), -12)))<$(=NUM(AddMonths(makedate($(vYear),$(vMonth),1), 0)))'}>}COUNTER)

My problem is that I need another test on the field FASTTRACK_SENT_NUM in this set analysis.

In addition to the test above I also need to select records where FASTTRACK_SENT_NUM <= FASTTRACK_DUE_NUM. 

Both FASTTRACK_SENT_NUM and FASTTRACK_DUE_NUM are date-fields converted to numeric format in the load script and they have exactly the same format.

How will the set analysis look like after including this extra test?

Best regards

Torunn

1 Solution

Accepted Solutions
Gysbert_Wassenaar

You're best off with calculating a flag field in the script. See attached qvw


talk is cheap, supply exceeds demand

View solution in original post

7 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

Sum(If(FASTTRACK_SENT_NUM <= FASTTRACK_DUE_NUM, count ({$<FASTTRACK_SENT_NUM={'>$(=NUM(AddMonths(makedate($(vYear),$(vMonth),1), -12)))<$(=NUM(AddMonths(makedate($(vYear),$(vMonth),1), 0)))'}>} COUNTER) ))

Regards,

Jagan.

Anonymous
Not applicable
Author

Hi Jagan!

First of all thank you for responding on my problem!

I have tried your suggestion, but I don't get this to work.  I do only get ' - ' as the result in the column. 

I don't know if you have som other suggestions that I can try?

Best regards

Torunn

Gysbert_Wassenaar

Try:

count ({$<FASTTRACK_SENT_NUM= {"=FASTTRACK_SENT_NUM<=FASTTRACK_DUE_NUM"},

FASTTRACK_SENT_NUM={'>$(=NUM(AddMonths(makedate($(vYear),$(vMonth),1), -12)))<$(=NUM(AddMonths(makedate($(vYear),$(vMonth),1), 0)))'}>}COUNTER)

If both date fields are in the same table, you could add a field to flag if FASTTRACK_SENT_NUM <= FASTTRACK_DUE_NUM:

if(FASTTRACK_SENT_NUM <= FASTTRACK_DUE_NUM, 1, 0) as fFTSentBeforeDue. Then you can simply use the new field in your set analysis expression.

Can you share a sample document? You can upload files by clicking on the Use advanced editor link after you click on the Reply button.

edit: changed the first expression so it returns a result. But better use the flag field


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Hi Gysbert!

I have tried your suggestion and I do now get ' 0 ' as the result of the expression.   I know there are records that should match the expression.  Do you have any more ideas that I could try? 

Best regards

Torunn

Anonymous
Not applicable
Author

Hei Gysbert!

I could not attach the total qvw because this is a part of a big model, but I have made a small qvw with the fields you need.

My need is to count number of records (%Quote_id) with "fast-track-sent" last month and check how many that was sent within "fast-track-due" that month.

You can see the table I need in the qvw.  Note that the source-data includes records for several months and that is why the expression needs several tests on the field "fast-track-sent".

I hope the attached file can help you.

Best regards

Torunn

Gysbert_Wassenaar

You're best off with calculating a flag field in the script. See attached qvw


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Thank's a lot Gysbert!

I shall do as you suggest and calculate a flag field in the script.

Best regards

Torunn