Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Author

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!

View solution in original post

5 Replies
MayilVahanan

Hi

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

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

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
Partner - Creator
Partner - Creator

Simon,

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

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

Not applicable
Author

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
Author

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.