In all programming environments there is a need for quotation marks, and QlikView is no exception. But which symbol should you use? " ", [ ], ` ` or ' '? This post will try to explain the differences between the different quotation marks. When creating the script or an expression in QlikView, you need to reference fields, explicit values and variables. To do this correctly, you sometimes need to write the string inside a pair of quotation marks. One common case is when a field name contains a symbol that prevents QlikView from parsing it correctly, like a space or a minus sign. For example, if you have a field called Unit Cost, then Load Unit Cost will cause a syntax error since QlikView expects an "as" or a comma after the word "Unit". If you instead write Load [Unit Cost] QlikView will load the field Unit Cost. Finally, if you write Load 'Unit Cost' QlikView will load the text string "Unit Cost" as field value. Hence, it is important that you choose the correct quotation mark. So, what are the rules? Which quote should I use? Single? Double? Square brackets? There are three basic rules: 1. Single quotes are used to quote literals, e.g. strings that should be used as field values. 2. Inside a Load statement, to the left of the as, double quotes are used to quote source field references, i.e. names of fields. 3. Double quotes can always be substituted by square brackets or by grave accents. With these three rules, most cases are covered. However, they dont cover everything, so I'll continue: In the script, but outside a Load statement, double quotes denote a variable reference and not a field reference. If double quotes are used, the enclosed string will be interpreted as a variable and the value of the variable will be used. A general rule in QlikView is that field references inside a Load must refer to the fields in the input table the source of the Load statement. They are source field references or in-context field references. Aliases and fields that are created in the Load cannot be referred since they do not exist in the source. There are however a couple of exceptions: the functions Peek() and Exists(). The first parameters of these functions refer to fields that either have already been created or are in the output of the Load. These are out-of-context field references. Out-of-context field references and table references, e.g. the parameters in NoOfRows() and Peek(), should be regarded as literals and therefore need single quotes. Finally, in many places you are free to use any of the four quotation methods, e.g. Inside a Set statement, to the right of the = Inside a Load statement, to the right of the as In places where QlikView expects a file name, a URL or a table name Defining the beginning and end of an inline table For the first parameter of Peek() or Exists() when used inside a Load I have deliberately chosen not to say anything about SELECT statements. The reason is that the rules depend on which database and which ODBC/OLEDB you have. But usually, rules 1-3 apply there also. With this, I hope that the QlikView quoteology is a little clearer. HIC 3899 Views Tags: exists , peek , quotes , escape_characters , quotations , single_quote , literals , noofrows , field_references , double_quote QlikView Quoteology Posted by Henric Cronstrm in QlikView Design Blog on Apr 9, 2013 10:45:32 AM 11 Comments Steve Dark Apr 9, 2013 11:23 AM Hi Henric - thanks for this - another very useful post I can see myself pointing a number of people this way. The one I find slightly counter-intutive is the GetCurrentField function. As a function it feels like it should require single quotes (in the same was as NoOfRows and Peek) but actually square brackets are required when spaces are present. The other thing I see people struggle with sometimes is putting a single quote into a variable, like this: Page 1 of 3 QlikView Design Blog : QlikView Quoteology | Qlik Community 6/11/2014 http://community.qlik.com/blogs/qlikviewdesignblog/2013/04/09/quoteology Like (3) let vString ='that's a problem'; I tend to fix this with a replace on an un-used character: let vString =replace('thats fixed it', '', chr(39)); Like (3) Henric CronstrmApr 9, 2013 3:32 PM (in response to Steve Dark) You're right that putting an apostrophe into a string is sometimes cumbersome. Your solution is a good one and I can only recommend to use the replace function here. In your specific case, there is however a simpler solution: Set vString ="that's not a problem"; In other words: you can use other quotation marks in a Set statement. HIC Like (0) orsh_ Apr 10, 2013 10:07 AM Thanks, Henric - useful stuff, as always. Like (2) swuehl Apr 10, 2013 10:18 AM (in response to Henric Cronstrm) Thank you very much for your great series, Henric, also for your comments, containing almost every single time some useful piece of information. Any chance that some of the stuff you and your collegues post in the design blog will find its way into the offical docs (Ref manual and HELP)? My personal feeling is that there was not much work on these docs the past 2 years, and it would be great not only for starters with QV but for all of us to find a more detailed, correct description of the QV functionality where I think I should find it first place (though I started to archive your series anyway). Like (0) PremKumar Thangallapally Apr 12, 2013 1:56 AM (in response to Henric Cronstrm) Thanks for yur usefull informaton,good disscussion ,.as always Like (0) Ralf Narfeldt Apr 12, 2013 8:50 AM Great blog post! I can confirm that the official documentation (Reference manual and Help) will be updated and improved in the area of how to use quotation marks. Like (0) Angad Singh J un 9, 2014 3:02 AM HIC, Can you help us know about quoteology being used inside Set Analysis and related scenarios. If already done, can you please share that with us. Thanks, Angad Like (1) Henric CronstrmJ un 9, 2014 4:24 PM (in response to Angad Singh) Today, in Set Analysis, it doesn't matter whether you use single or double quotes. They both interpret the content according to bullet two below. But it should matter. There is a bug here... And one day it will get fixed. It should be this way: Single quotes: Literal match with field value. Case sensitive. Doubl e quotes: A search. The string may start with <or >for numeric searches. May start with =for expression searches. May contain wildcards. Case insensitive. Double quotes can be exchanged with []. In other words, 'A*' should be a case sensitive match with a field value that is two characters long and has an A as first letter and an asterisk as 2nd, whereas "A*" should be a case insensitive search for all strings beginning with 'A'. So, you need to change any single quotes in your set analysis to double quotes, in order to make it future-proof. HIC Like (0) Angad Singh J un 9, 2014 8:51 AM (in response to Henric Cronstrm) Thank you so much HIC for the knowledge sharing. Page 2 of 3 QlikView Design Blog : QlikView Quoteology | Qlik Community 6/11/2014 http://community.qlik.com/blogs/qlikviewdesignblog/2013/04/09/quoteology Sections Discussion Forums Resources Ideas Groups Blogs New to QlikView Blogs Business Discovery QlikView Design Community Manager Blog QlikView Support Updates Technical Bulletin All Blogs Qlik Sites Qlik.com Partner Portal Customer Portal Qlik Market Demos Trademarks Privacy Terms of Use Copyright 19932014 QlikTech International AB, All Rights Reserved. Like (0) Tormod Hanstad J un 10, 2014 3:33 AM If your inputfile (csv) contains " as a delimeter and a part of the text i.e Order_Id Text 9999999 "Flex_Pipe 32 " " (qoutationmark used as symbol for Inches) Now QlikView or any other read whats between the last " and the next delimeter " as one record and it will mess up your data. It took a while until I found the solution for this and not surprisingly, QlikView have a good one. Change the finction in the inputfile spec from MSQ(Microsoft standard qouting) to NOQUOTES. Now your qliviewfile will be correct. This odd example is taken from an old transactionsystem but som companies still have them and sometime we need to solve this as well. Tormod Hanstad Like (0) Mrcio Rodrigo Campestrini J un 10, 2014 2:26 PM HIC, thanks for share this post. Page 3 of 3 QlikView Design Blog : QlikView Quoteology | Qlik Community 6/11/2014 http://community.qlik.com/blogs/qlikviewdesignblog/2013/04/09/quoteology