5 Replies Latest reply: Aug 4, 2016 3:10 PM by jia li

# Set Analysis With a Date Variable

Hey everyone, I am having some issues with my set analysis. This is what I currently have.

Variable:

vMaxTransDate = max(TranDate)

Set Analysis:

=sum({<SalesStat = {'Open'}, TranDate = {'=\$(vMaxTransDate)'}>}SalesQty)

This is not giving me the SalesQty for that max date but instead its giving me all the SalesQty till that max date. Would love some help with this. Thank you in advance.

• ###### Re: Set Analysis With a Date Variable

Try one of these:

=Sum({<SalesStat = {'Open'}, TranDate = {'\$(=\$(vMaxTransDate))'}>}SalesQty)

or

=Sum({<SalesStat = {'Open'}, TranDate = {'\$(=vMaxTransDate)'}>}SalesQty)

• ###### Re: Set Analysis With a Date Variable

=sum({<SalesStat = {'Open'}, TranDate ={'\$(=\$(vMaxTransDate))'}>}SalesQty)

That worked. Thank you. Can you explain why this worked?

• ###### Re: Set Analysis With a Date Variable

That worked. Thank you. Can you explain why this worked?

I assume you haven't defined your variable with a leading equal sign, so you need the equal sign in the set modifier to evaluate your max() function, right?

• ###### Re: Set Analysis With a Date Variable

Yeah, you are correct. Thank you.

• ###### Re: Set Analysis With a Date Variable

Using an equal sign in the field modifier starts an advanced search, which you don't want here, you want to use a constant value element list.

Take care to format your value according to your format of TranDate:

Variable:

vMaxTransDate

=Date(max(TranDate),'MM/DD/YYYY')