Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using Addmonths in IF Statement for Dimension

Hi,

I use this if statement but it does not bring back 2 months, it brings back all available months in a Year.

if(date#(GLPeriod.PeriodNameRP,'MMM-YY') >= $(=addmonths(date#(only(GLPeriod.PeriodName),'MMM-YY'),-2))
,date#(GLPeriod.PeriodNameRP,'MMM-YY'))

Please let me know if i did any wrong.

Thanks

Dev

 

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

It worked when i created the function as variable
vMonth5 variable is set with =addmonths(date#(only(GLPeriod.PeriodName),'MMM-YY'),-5)
and in IF
=if(date#(GLPeriod.PeriodNameRP,'MMM-YY') >= vMonth5
,date#(GLPeriod.PeriodNameRP,'MMM-YY'))

 

 

View solution in original post

3 Replies
shwethaa
Contributor III
Contributor III

Hi Dev,
Try below expression
if(Date(date#(GLPeriod.PeriodNameRP,'MMM-YY')) >= Date(addmonths(Date(date#(Min(GLPeriod.PeriodName),'MMM-YY')),-2))
,Date(date#(GLPeriod.PeriodNameRP,'MMM-YY')))


-Shwetha A
Anonymous
Not applicable
Author

Nope, it gives Error in Calculated Dimension. But the window says Expression is Ok.
Anonymous
Not applicable
Author

It worked when i created the function as variable
vMonth5 variable is set with =addmonths(date#(only(GLPeriod.PeriodName),'MMM-YY'),-5)
and in IF
=if(date#(GLPeriod.PeriodNameRP,'MMM-YY') >= vMonth5
,date#(GLPeriod.PeriodNameRP,'MMM-YY'))