Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
saivina2920
Creator
Creator

How to add user input value along with my count expression (date comparison)

I written some count expression as mentioned below.

=Count({<EMPJOINDATE={"(>=$(vCalcDate)<=$(vToday))"},SECTION= {'*AB-*','*CD-*'}>} DISTINCT EMP_NUMBER)

Along with the above, i want to pass one more condition which is already filled in listbox. ListBox contains number of Sequence values (Days)

Example :

DAYS (ListBOX)
-----
1
2
3
4
5
6
7
8
9
...
...
100


When i select the listbox, then my count automatically should get change. I tried below expression. But, nothing will reflect.

what i want to do..?


Note : i created variable (vUserInput) ==> GetFieldSelections(DAYS)

 

=Count({<EMPJOINDATE={"(>=$(vCalcDate)<=$(vToday) + vUserInput)"},SECTION= {'*AB-*','*CD-*'}>} DISTINCT EMP_NUMBER)

will the syntax is correct...?

Labels (3)
1 Solution

Accepted Solutions
rubenmarin

You can try using a variable that does the addition:
New Variable vUserDate = =date('$(vToday)'+5,'DD-MM-YYYY')

And try using this variable:
=Count({<IssueDate={">=$(vIssueCalDate)<=$(vUserDate)"},EMP_SECTION= {'*B-*','*C-*'}>} DISTINCT EMP_NUMBER)

You can add the variable to an input box to check calculated values.
If still doesn't works it has nothing to do with the days selected by the user, it's an expression issue

View solution in original post

11 Replies
rubenmarin

Hi, if the * for SECTION means [any string] it should be between double quotes or it will look for the literal *-AB-* (exactly that value).
Also dates can be tricky, try step by step, first with only SECTION in set analysis and then add EMPJOINDATE to check where is the error.
saivina2920
Creator
Creator
Author

I didn't get any error.
i just want to add user input condition along with the date.
For example,
if user select 5, then it should consider as "5 Days".
then i want to add along with the date expression..
This logic and syntax is correct or not...
rubenmarin

Not getting an error doesn't means it will work as you want it to work. Which are the values for SECTION? Have you followed my advise to add set analysis step by step?

I think that dates should be calculated in an additional dollar-expansion:
EMPJOINDATE={">=$(vCalcDate)<=$(=$(vToday) + vUserInput)"}
saivina2920
Creator
Creator
Author

anything we want to format vUserInput as date.
will it calculate the count as days even if i use vUserInput....?

The problem is "vUserInput" not able to read the values at all.

when i select the days listbox, it will not be reflect anything in my count.

Note : i am filling values in list box using below script.

LOAD recno() as SeqDays
AUTOGENERATE 100; // maximum number allowed

saivina2920
Creator
Creator
Author

Any update pls...
rubenmarin

can you post a sample to check?

Maybe EMPJOINDATE={">=$(vCalcDate)<=$(=$(vToday) + $(vUserInput))"}

 

There can be many possible issues when working with dates

saivina2920
Creator
Creator
Author

i am filling values in list box using below script.

LOAD recno() as SeqDays
AUTOGENERATE 100; // maximum number allowed
saivina2920
Creator
Creator
Author

1. GET_DAYS:
LOAD recno() as ValueSeqDays
AUTOGENERATE 100; // maximum number allowed


2. Create New variable named ==>  "vUserInput"

So, vUserInput =GetFieldSelections(ValueSeqDays)

and also,

New Variable vIssueCalDate = =date((vToday-5),'DD-MM-YYYY')
New Variable vToday = =date(Today(),'DD-MM-YYYY')


3. Load and fill the values in ListBox columnname "ValueSeqDays"

4. My condition Expression for count to display in Text Object

=Count({<IssueDate={">=$(vIssueCalDate)<=$(=$(vToday) + vUserInput)"},EMP_SECTION= {'*B-*','*C-*'}>} DISTINCT EMP_NUMBER)

When i click my list box it should automatically change the count. but, it is not reflecting.???

rubenmarin

You can try using a variable that does the addition:
New Variable vUserDate = =date('$(vToday)'+5,'DD-MM-YYYY')

And try using this variable:
=Count({<IssueDate={">=$(vIssueCalDate)<=$(vUserDate)"},EMP_SECTION= {'*B-*','*C-*'}>} DISTINCT EMP_NUMBER)

You can add the variable to an input box to check calculated values.
If still doesn't works it has nothing to do with the days selected by the user, it's an expression issue