Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Set Analysis variable with parameters?

I am trying to make a set analysis variable that takes a parameter, so I can pass in any date I want.

Like so:

vDateSetAnalysisExpr = {$ <Year=, Month=, Week=, Date={'$1'}>}

And then I would use it like so:

sum($(vDateSetAnalysisExpr('1/1/2012')) Revenue)

But I haven't been able to get it to work. If I use the same set analysis expression variable using a literal '1/1/2012' in the variable itself, it works just fine.

Any thoughts on if this is possible, and if so how?

Thanks,

     -Simon-

1 Solution

Accepted Solutions
Not applicable

Re: Set Analysis variable with parameters?

I found my problem...

In the set analysis variable, where i had

Date={'$1'} //<-- WRONG

I should have had

Date={$1} //<-- RIGHT - no quotes!

*sigh*

Thanks Mayil!

5 Replies

Re: Set Analysis variable with parameters?

Hi

     If so, can you check the format for date? its also in dd/mm/yyyy format?

Not applicable

Re: Set Analysis variable with parameters?

I found my problem...

In the set analysis variable, where i had

Date={'$1'} //<-- WRONG

I should have had

Date={$1} //<-- RIGHT - no quotes!

*sigh*

Thanks Mayil!

wgonzalez
Contributor

Re: Set Analysis variable with parameters?

Simon,

Where did you write the expansion variable, in the script?

vDateSetAnalysisExpr = {$ <Year=, Month=, Week=, Date={$1}>}

Not applicable

Re: Set Analysis variable with parameters?

Wilfredo,

I used the variable in charts like so:

sum($(vDateSetAnalysisExpr('1/1/2012')) Revenue)

to get the sum of revenue for just 1/1/2012, etc.

Not applicable

Re: Set Analysis variable with parameters?

And if I want to use it with a variable, I can do it like this:

sum($(vDateSetAnalysisExpr('$(=date(v3WeeksBack))')) Revenue)

I found it necessary to do this even if the variable (v3WeeksBack in this case) is already a date. Putting it in a dollar expansion with an eqauls sign $(=date(v3WeeksBack)) forces it to be evaluated before being passed to the set analysis variable as a parameter.

Community Browser