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: 
Anonymous
Not applicable

Set analysis with variable

Need help to write set expression using variable.

My current expression is:

count(DISTINCT(If(SLA_INDICATOR='SLA_MET' and Ticket_Type ='BPS Tickets' and [Referred to CPS] ='Y' and [Resolved Year]=Year(today()) and [Resolved Date]<=vInputDate+1 ,[TR #])))

I tried using the below to write the set expression with variable but its not working

count(DISTINCT {<SLA_INDICATOR={'SLA_MET'},Ticket_Type={'BPS Tickets'},[Referred to CPS]={'Y'},[Resolved Year]={"$(=year(today()))"},[Resolved Date]={"<=$(vInputDate+1)"}>}Id)

Can anybody please help how to write the expression with the variable?


1 Solution

Accepted Solutions
sunny_talwar

Try this (you might have misplaced a parenthesis):

=Count(DISTINCT {<SLA_INDICATOR = {'SLA_MET'}, Ticket_Type={'BPS Tickets'}, [Referred to CPS] = {'Y'}, [Resolved Year] = {"$(=Year(Today()))"}, [Resolved date] = {"<=$(=timestamp(vInputDate+1),'M/D/YYYY h:mm:ss TT')"}>}Id)

Try this:

=Count(DISTINCT {<SLA_INDICATOR = {'SLA_MET'}, Ticket_Type={'BPS Tickets'}, [Referred to CPS] = {'Y'}, [Resolved Year] = {"$(=Year(Today()))"}, [Resolved date] = {"<=$(=timestamp(vInputDate+1,'M/D/YYYY h:mm:ss TT'))"}>}Id)

View solution in original post

7 Replies
sunny_talwar

Try this:

Count(DISTINCT {<SLA_INDICATOR = {'SLA_MET'}, Ticket_Type={'BPS Tickets'}, [Referred to CPS] = {'Y'}, [Resolved Year] = {"$(=Year(Today()))"}, [Resolved Date] = {"<=$(=vInputDate+1)"}>}Id)

pipuindia99
Creator III
Creator III

Count(DISTINCT {<SLA_INDICATOR = {'SLA_MET'}, Ticket_Type={'BPS Tickets'}, [Referred to CPS] = {'Y'}, [Resolved Year] = {"$(=Year(Today()))"}, [Resolved Date] = {"<=$(=vInputDate+1)"}>}Id)


What Sunny has given should work...

Anonymous
Not applicable
Author

Hi Sunny

This doesnt seem to work. I have defined through input box and not in the load script

sunny_talwar

What is the resolved field format? May be you need that here:

Count(DISTINCT {<SLA_INDICATOR = {'SLA_MET'}, Ticket_Type={'BPS Tickets'}, [Referred to CPS] = {'Y'}, [Resolved Year] = {"$(=Year(Today()))"}, [Resolved Date] = {"<=$(=Date(vInputDate+1, 'DateFieldFormatHere'))"}>}Id)

Anonymous
Not applicable
Author

My [Resolved Date] is in timestamp format such 11/16/2016 12:57:17 PM and vInput date is in M/D/YYYY format so I changed the expression to the below but its still not working..

=Count(DISTINCT {<SLA_INDICATOR = {'SLA_MET'}, Ticket_Type={'BPS Tickets'}, [Referred to CPS] = {'Y'}, [Resolved Year] = {"$(=Year(Today()))"}, [Resolved date] = {"<=$(=timestamp(vInputDate+1),'M/D/YYYY h:mm:ss TT')"}>}Id)

sunny_talwar

Try this (you might have misplaced a parenthesis):

=Count(DISTINCT {<SLA_INDICATOR = {'SLA_MET'}, Ticket_Type={'BPS Tickets'}, [Referred to CPS] = {'Y'}, [Resolved Year] = {"$(=Year(Today()))"}, [Resolved date] = {"<=$(=timestamp(vInputDate+1),'M/D/YYYY h:mm:ss TT')"}>}Id)

Try this:

=Count(DISTINCT {<SLA_INDICATOR = {'SLA_MET'}, Ticket_Type={'BPS Tickets'}, [Referred to CPS] = {'Y'}, [Resolved Year] = {"$(=Year(Today()))"}, [Resolved date] = {"<=$(=timestamp(vInputDate+1,'M/D/YYYY h:mm:ss TT'))"}>}Id)

Anonymous
Not applicable
Author

Thanks Sunny. It worked. I think the bracket was missed out