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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to avoid executing the code is the field in the code are blank

Hi

Below is the code I am using in the dimension field for displaying the something like A1-09, where A1 is the month and 09 is the year as per our understanding. I don't want the below code to be executed if FINISHPERIOD and FINISH_YEAR are blank. Please let me know how to do this.

=FINISHPERIOD&'-'&right(FINISH_YEAR,2)


See the below image, I think I am getting - (because of this &'-'& in the above code)when both the fields are blank.



4 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This should do the trick:

=If(Len(FINISHPERIOD) > 0 And Len(FINISH_YEAR) > 0, FINISHPERIOD & '-' & right(FINISH_YEAR, 2))

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author


Jonathan Dienst wrote:
This should do the trick:
=If(Len(FINISHPERIOD) > 0 And Len(FINISH_YEAR) > 0, FINISHPERIOD & '-' & right(FINISH_YEAR, 2))<div></div>


Just now I did exactly the same thing and seeing your code after that. Many thanks for your support.

Cheers

Not applicable
Author


Attitude wrote:
<pre>
Jonathan Dienst wrote:
This should do the trick:
=If(Len(FINISHPERIOD) > 0 And Len(FINISH_YEAR) > 0, FINISHPERIOD & '-' & right(FINISH_YEAR, 2))<div></div>


Just now I did exactly the same thing and seeing your code after that. Many thanks for your support.

Cheers



Hi
To be on the safe side, you might also use trim:

len



(trim(FINISHPERIOD))>0

Rgds
Jonas

Consultant @ Optivasys | http://www.optivasys.se

Not applicable
Author

Thanks Jonas!

You are right too...