Skip to main content
Announcements
Join us on Sept. 17 to hear how our new GenAI Assistant empowers data professionals: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
A_C
Contributor
Contributor

SQL Select Value ()

Hi All,

I need to write a sql select statement to return a match from 3 different columns.

Normally I would use something along these lines to pull from one column and if blank/null then pull from another.

Do I need to use a case statement? If statements? Not sure exactly if Qliksense supports all SQL queries/functions.

Here is my query for what I currently have. I need to pull the existing information from the source_from column first then from the source_name column 2nd if the source_from column is blank/null and then finally MI_loc if both source_from and source_name are blank/null.

VALUE (SUS.SOURCE_FROM || ' - ' ||
SUS.SOURCE_NAME,
SUH.MI_LOC) as SOURCE_OF_MATRL

Many Thanks

2 Replies
andoryuu
Creator III
Creator III

Typically in SQL you would use a coalesce statement, but Qlik Sense does not have coalesce. You have to test for nulls and blanks. The easiest way to do this is with if statements and len statements. Keep in mind that if statements are very slow so it's better to handle this in the data load before hand if possible. In a Qlik Sense field you would use:

=if(len(SOURCE_FROM)>0,SOURCE_FROM,if(len(SOURCE_NAME)>0,SOURCE_NAME,MI_LOC)))
A_C
Contributor
Contributor
Author

I want to share my entire script with you. Once I plugged it in and ran it I got an error, but when I removed to debug it ran just fine.

See my script and you will get a better picture of where I am trying to pull it from