5 Replies Latest reply: Jan 12, 2016 12:32 PM by Miguel Braga

# Problem with Date and AddDate

Hi everyone,

I have been having a problem with a formula in set analysis:

sum(aggr(

if([Payment Type ID] = 1

,sum({< [Calendar Year Month ID] =  {'\$(=max([Calendar Year Month ID]))'}, [Payment Type ID] = {1}, [Calendar Date]=  {'<\$(=date(today(0)-4))'}>}  _f_OK_POSITIVE_TRX)

,sum({< [Calendar Year Month ID] =  {'\$(=max([Calendar Year Month ID])-1)'},[Payment Type ID] = {2},[Calendar Date]=  {'<\$(=date(AddMonths(today(0)-4,-1))'}>}  _f_OK_POSITIVE_TRX)

)

,[Merchant ID], [Payment Type ID],[Calendar Date]))

For some reason this part:

Works in a text box, but when I use it the set analysis it doesn't. Is there anything I'm missing?

• ###### Re: Problem with Date and AddDate

That's hard to answer with the information provided. In general

- Check that the dollar sign expansion returns a date value with the same format as the field you are modifying ([Calendar Date]).

- If you remove the expression label in a straight table chart, you can hover over the label and see the expanded expression, to check that all dollar sign expansions work as intended

- Check that there are values for your field modifier search to return (i.e. Calendar Dates before the expanded date).

- Also check that potential user selections or other field modifier don't render the set incompatible (e.g. check the field modifications for Calendar Year Month ID is compatible to your Calendar Date selection and all possible user selections in calendar fields.

As you see, multiple possible causes why the expression might not work. It's often much easier to help if you could post  a small sample QVW.

Hi,

• ###### Re: Problem with Date and AddDate

Where you have this:

Change to this:

If don't work, report and/or elaborate your question better.

Regards,

MB

• ###### Re: Problem with Date and AddDate

Hi everyone thanks for your help. I can't beleive I was banging my head for so long. It was just an extra parenthesis.

This worked: