0 valutazioniIl 0% ha trovato utile questo documento (0 voti)
47 visualizzazioni5 pagine
This document covers couple of scenario, showing the power of Qlikview scripting and way to achieve it. I will cover the first 5 points and remaining points and any additional topics in separate document.
This document covers couple of scenario, showing the power of Qlikview scripting and way to achieve it. I will cover the first 5 points and remaining points and any additional topics in separate document.
This document covers couple of scenario, showing the power of Qlikview scripting and way to achieve it. I will cover the first 5 points and remaining points and any additional topics in separate document.
This document covers couple of scenario, showing the power of Qlikview scripting and way to achieve it Some of sample coding techniques in Qlikview 1. Use of subfield 2. Pick and Match to replace if command 3. Dual Command Usage 4. Use of variable in variable in variable 5. Replacing IntervalMatch with Full Join 6. Optimization using Qlikview 7. Set Analysis 8. Use of library 9. Others 10. Sorting Techniques for Pivot table 11. Showing the value for each Dimension (in Pivot table) In this document, I will cover the first 5 points and remaining points and any additional topics in separate document (Coding Techniques 2) Sample Code Subfield/Pick/Dual/Match Data: Load Dual(RegionText, Match(RegionText,LN,TK,HK)) as Region, Pick(Match(RegionText, LN, HK, TK), 1.0,1.25, 1.50) as Factor, *; Load Subfield(LN,TK,HK, ,) as RegionText, Ceil(Rand() * 100) as Amount AutoGenerate(100); The following example shows you how to use subfield to generate 3 fields from a single value -> Subfield(LN,TK,HK, ,) as RegionText, Pick and Match to replace If condition, applicable only for equal to expression Pick(Match(RegionText, LN, HK, TK, *), 1.0,1.25, 1.50,0.75) as Factor, Use of Dual Command to assign Numeric value to Region (Generally used for regional priority or Sorting) Dual(RegionText, Match(RegionText,LN,TK,HK)) as Region, Use of Dual Command to assign Numeric value to Region (Generally used for regional priority or Sorting) Use of variables: The following 2 examples slightly different in approach are used in the attached qvw showing the sum by region Set 1 using AmountYTD, AmountQTD etc, which is predefined Set 1: Let ReportType = WTD'; // The values of variable can WTD, MTD, QTD, YTD Let AmountYTD = sum(if ( CurrentYearFlag = 1, Amount))'; Let AmountQTD = sum(if ( CurrentQtrFlag = 1, Amount))'; Let AmountMTD = sum(if ( CurrentMonthFlag = 1, Amount))'; Let AmountWTD = sum(if ( CurrentWeekFlag = 1, Amount))'; Set 2 using FlagName and will be using this flag to find the values Set 2: Let FlagName = Current & Pick(match(ReportType,WTD,MTD,QTD,YTD), Week,Month,Qtr,Year) & Flag'; The use of variables can be multiple levels, in Qlikview, the output of one variable can be used as input to another variable The good part is it can be used on either of equation as in case-1, it is used on LHS and in case-2 it is used on RHS Use of Peek/Previous and Interval Match Scenario Table1: Records with Amount and TimeKey Table2: Records with FxRate and TimeKey Table 2 Does not have FxRate For all TimeKey, so assuming it has records for TimeKey 1,7, 30 only Then records 1-6 -> will use TimeKey = 1 7-29 -> will use TimeKey = 2 And 30 onwards will use TimeKey = 3 Example with Interval Match Keys: Load Alt(Peek(KeyEnd),-1)+1 as KeyStart, Key as KeyEnd, FX; Load (Recno() 1 )* 10 + 1 as Key, Rand() as FX Autogenerate(10); Concatenate(Key) Load KeyEnd + 1 as KeyStart, 1000 as KeyEnd, FX Resident Key where KeyEnd = peek(KeyEnd,-1); Data: Load recno() as Key, Round(Rand()*100) as Amount Autogenerate(100); IntervalMatch ( Key ) Load KeyStart, KeyEnd Resident Keys; Alternate Example with Left Join Data: Load recno() as Key, Round(Rand()*100) as Amount Autogenerate(100); Key: Load Alt(Peek(KeyEnd),-1)+1 as KeyStart, Key as KeyEnd, FX; Load (Recno() 1 )* 10 + 1 as Key, Rand() as FX Autogenerate(10); Concatenate(Key) Load KeyEnd + 1 as KeyStart, 1000 as KeyEnd Resident Key where KeyEnd = peek(KeyEnd,-1); Left Join(Data) Load * Resident Key; Drop Table Key; DataNew: Load Key, Amount, FX, KeyStart as Start, KeyEnd as End Resident Data Where Key >= KeyStart and Key <= KeyEnd; Drop Table Data; All the above examples show alternate ways of doing things in Qlikview. This document is more for understanding various features and alternatives rather than recommendation for a particular technique. The above examples are guidelines rather than rules http://kulbirminhas.wordpress.com/2012/02/27/coding-techniques-qlikview/ http://kulbirminhas.wordpress.com/2012/02/27/coding-techniques-qlikview/