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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Pulkit_Thukral
Partner - Creator II
Partner - Creator II

p funtion with date range

Hi All,

How can we use a date range expresson inside p() .

Currently i am using the below expression which is not working:-

MachineName=p({<Date={">=$(=date(floor(monthstart(addmonths(today()-4))),'DD-MM-YYYY'))"}*{'<$(=date(floor(monthstart(addmonths(today()-1))),'DD-MM-YYYY'))"} )



12 Replies
swuehl
MVP
MVP

'not working' is not really helping us to find out what is causing the issue.

Try

=Count(DISTINCT {< Date={">=$(=date(monthstart(addmonths(today(),-4))))<=$(=date(monthstart(addmonths(today(),-1))))"} >} Date)

or what ever set expression in your p() function you want to test in a text box.

It must return the distinct number of dates in your date range (if you are using a master calendar in your data model, you can easily compare to a calendar on your wall).

If this is 'not working', please specify what you expect to see and what you get.

Regards,

Stefan

swuehl
MVP
MVP

pulkit thukral wrote:

i checked with 2 formats-

date(Date,'MM/DD/YYYY')

and

date(Date,'MM/DD/YYYY hh:mm:ss')

You need to check what the field format of the Date values is, e.g. by looking at a list box with default number formatting. If you are using Date() function, you are reformatting the field format.

Why don’t my dates work?

Dates in Set Analysis

Pulkit_Thukral
Partner - Creator II
Partner - Creator II
Author

Thanks for writing.

Please find my exact requirement mentioned below.

i Wrote an expression count of machines that were patched between nov-15 to feb-16.

This worked perfectly with the expression:-

count(distinct {<Patch_Status={'Success'},Dategenerated={">=$(=date(floor(monthstart(addmonths(today()-4))),'DD-MM-YYYY'))"}*{'<$(=date(floor(monthstart(addmonths(today()-1))),'DD-MM-YYYY'))"} >}machines

Now, i have to create a text box showing the count of machines that were patched bet nov-15 to feb 16 (as defined in top expression) but are not patched betweeaug-15 to oct-15 (i.e last 3 - 6 months).

Example:

Suppose 80 machines were patched between nov-15 to feb-16 as per the first expression.

Now , i need to find that among these 80 machines,how many machines were not patched between aug-15 to oct-15.

What could be the possible way of showing this count.?