Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
johnlauridsen
Contributor III
Contributor III

Can a variable be used in a Set Analysis

This variable is working: $(CM)

But when putting it in a Set Analysis it doesn't:

sum

({$<InvoiceYear={$(=Only(InvoiceYear)-1)}

,



InvoiceMonth={"<=$(=max(InvoiceMonth))"}

>}



$(CM))

The result is "-"

I have also tried to take the formula from the variable (which is 2 other variables) and copied this in instead of the $(CM) - No result.

Thanks in advance for your help



3 Replies
stephencredmond
Luminary Alumni
Luminary Alumni

Hi John,

Set analysis doesn't apply to variables - any more than Sum, Avg, Count do!

Your variable will have a value - e.g. CM = 5. A sum statement like this:

Sum(CM) or Sum($(CM)) {both are equivalent}

is actually saying:

Sum(5)

It doesn't make any sense.

Regards,

Stephen

Not applicable

Instead of using a variable you should be able to use a field containing the name of the field to summarize.

i.e. you have a field called MyFieldName where the value is MyField ok ?

Then in your expression you put SUM({$<InvoiceYear={$(=Only(InvoiceYear_1)},InvoiceMonth={"<=$(=max(InvoiceMonth))"}>} $(=only(MyFieldName))).

This will work ( in this case I advise that you mandatory always one value selected for the field MyFieldName.

Rgds,

Sébastien

Not applicable

What is the definition of your variable? You said it was made up of other variables, could you post the definitions of those.

You can use a variable in the context you describe. If your variable contains an expression, then that expression would be evaluated as part of the Sum.

Also, have you tried removing the Set Analysis portion to see if that is at fault? If your expression works, Sum($(CM)) should give results.