Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
saumyashah90
Specialist
Specialist

Alternate State , If condition

Hi ,

I have a expression.

=If(Fin_Months='Jan' or Fin_Months='Feb' or Fin_Months='Mar','1Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Apr' or Fin_Months='May' or Fin_Months='Jun','2Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Jul' or Fin_Months='Aug' or Fin_Months='Sep','3Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Oct' or Fin_Months='Nov' or Fin_Months='Dec','4Q'&(Right(Fin_Years,2)-1),

))))

This works good when i keep it in text box , but when i keep it in variable it doesnt provide  any output.

I want to use this where Fin_Months and Fin_Years are in different alternate state.

Data format Fin_Months and Fin_Years is text.

Any help would be appreciated.

1 Solution

Accepted Solutions
sunny_talwar

May be just wrap it around with Only function and give it a alternate state in the set analysis

=Only({AlternateState}

If(Fin_Months='Jan' or Fin_Months='Feb' or Fin_Months='Mar','1Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Apr' or Fin_Months='May' or Fin_Months='Jun','2Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Jul' or Fin_Months='Aug' or Fin_Months='Sep','3Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Oct' or Fin_Months='Nov' or Fin_Months='Dec','4Q'&(Right(Fin_Years,2)-1),

)))))

View solution in original post

4 Replies
Anonymous
Not applicable

Are you calling the variable correctly like this ? $(YOURVARIABLE)

sunny_talwar

May be just wrap it around with Only function and give it a alternate state in the set analysis

=Only({AlternateState}

If(Fin_Months='Jan' or Fin_Months='Feb' or Fin_Months='Mar','1Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Apr' or Fin_Months='May' or Fin_Months='Jun','2Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Jul' or Fin_Months='Aug' or Fin_Months='Sep','3Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Oct' or Fin_Months='Nov' or Fin_Months='Dec','4Q'&(Right(Fin_Years,2)-1),

)))))

sunny_talwar

Also, you might want to simplify your expression like this

Only({AlternateState}Ceil(Month(Date#(Fin_Months, 'MMM'))/3) & 'Q'&(Right(Fin_Years, 2)-1))

shiveshsingh
Master
Master

Can you try this

=only(If(Fin_Months='Jan' or Fin_Months='Feb' or Fin_Months='Mar','1Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Apr' or Fin_Months='May' or Fin_Months='Jun','2Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Jul' or Fin_Months='Aug' or Fin_Months='Sep','3Q'&(Right(Fin_Years,2)-1),

If(Fin_Months='Oct' or Fin_Months='Nov' or Fin_Months='Dec','4Q'&(Right(Fin_Years,2)-1),

)))))