Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

New to set analysis. Why doesn't this work?

I am trying to use set analysis almost for the first time.  I think I'm getting hung up on syntax.

QlikView says the expression is OK, but it is still gives me the sum of cloudAgentSpaceUsedGB instead of limiting the set to the most recent cloudAgentSnapshotDate.  Am I doing something wrong?

sum( {$<cloudAgentSnapshotDate = {"=max(cloudAgentSnapshotDate)"} >} cloudAgentSpaceUsedGB)

Thanks!

-Kevin

1 Solution

Accepted Solutions
Employee
Employee

Re: New to set analysis. Why doesn't this work?

Date comparisons can be tricky.  Try going with a literal (single quotes)  instead of a search  (double quotes)

change:

sum(  {$< = {"=max(cloudAgentSnapshotDate)"} >} cloudAgentSpaceUsedGB)

to:

=sum( {$<cloudAgentSnapshotDate={'$(=Date(max(cloudAgentSnapshotDate)))'}>}   cloudAgentSpaceUsedGB)

3 Replies
Employee
Employee

Re: New to set analysis. Why doesn't this work?

Date comparisons can be tricky.  Try going with a literal (single quotes)  instead of a search  (double quotes)

change:

sum(  {$< = {"=max(cloudAgentSnapshotDate)"} >} cloudAgentSpaceUsedGB)

to:

=sum( {$<cloudAgentSnapshotDate={'$(=Date(max(cloudAgentSnapshotDate)))'}>}   cloudAgentSpaceUsedGB)

jsaradhi
Valued Contributor

Re: New to set analysis. Why doesn't this work?

few things to consider:

1. format of the date. max(cloudAgentSnapshotDate) will return numeric value of the date which is being compared to formatted time value, cloudAgentSnapshotDate.

2. Date function with the correct formatting should help. something like - Date(max(cloudAgentSnapshotDate), 'MM/DD/YYYY') - modify the format to your application. if the format is not correct, the sum value will not be what you expect as well.

3. i would set a variable and use it in the set analysis expression. so define a variable vMaxDate as the expression in step 2 and for your sum expression the following:

sum(  {$<cloudAgentSnapshotDate = {"$(=vMaxDate)"} >} cloudAgentSpaceUsedGB)

hope this helps.

Not applicable

Re: New to set analysis. Why doesn't this work?

Thanks, Jonathan!  It didn't like the Date function, but the single quotes did the trick.  I appreciate your help.

Community Browser