Saturday, April 16, 2016

Tip  - Do not mix case when naming Qlikview variable/identifiers  
 
QlikView’s has a case sensitive scripting language i.e. the case of a variable/identifier is important e.g. QlikView, QLIKVIEW, qlikview are all considered different identifiers to QlikView.  
  
This, in itself is not an issue, but when combined QlikView’s absence of mandatory variable declaration can cause issues. A simple typo can cause QlikView to automatically create a new variable with a slightly different name from the one you were expecting leading to time consuming troubleshooting.  
  
The recommendation is to always use consistent case i.e. all lower, or all upper and if you need to separate words in an identifier name then use the underscore character. This recommendation differs from all QlikView training and reference materials.  
  
Examples:  
let ProcessingPeriodEndDate = Date( WeekEnd(Today(),-1), 'MM/DD/YYYY') ;   
let ProcessingPeriodEndDatetime   = Date(ProcessingPeriodendDate, 'YYYY-MM-DD') & '-23.59.59.999999';     
Can you spot the error? The 2nd reference to “ProcessingPeriodEndDate” has a typo and QlikView will attempt to get a value from this new variable instead of the one we want it to.  
 
Highlighted: 
let ProcessingPeriodEndDatetime   = Date(ProcessingPeriodendDate, 'YYYY-MM-DD') & '-23.59.59.999999';    

Typos regarding case are less likely if the same case is used throughout the naming convention because they jump right out at you in the script:  
let v_processing_period_end_date = Date( WeekEnd(Today(),-1), 'MM/DD/YYYY') ;   
let V_processing_period_end_datetime   = Date( v_processing_period_End_date, 'YYYY-MM-DD') & '-23.59.59.999999';     
Can you spot the typos now?  

Highlighted: 
 let V_processing_period_end_datetime   = Date( v_processing_period_End_date, 'YYYY-MM-DD') & '-23.59.59.999999'; 
 
note: Script syntax FORCE CASE e.g. FORCE CASE UPPER or FORCE CASE LOWER, will control the allowable case on field names but there appears to be no obvious equivalent for variable names 
 

No comments:

Post a Comment