QlikCommunity Tip: Add Code to your Content

    A quick how-to for copying and pasting code into QlikCommunity.  Following this will help other users read and understand your code, which will help everyone solve problems easier.

     

    Before we start: Disable "Copy as Rich Text" in QlikView

    QlikView can copy and paste code as Rich Text (which includes colors and formatting or Plain Text (easier to read on this site).  To set this preference, open up QlikView and go to Settings > User Preferences > Editor Tab and uncheck the Copy as RTF checkbox:

     

    copy-as-rtf-checkbox.png

     

    Step 1: Copy your QlikView code

    Open up the Script Editor or Expression Editor and copy (CTRL+C) your code to the clipboard.

     

    Step 2: Use the "Insert" Button

    Once you have opened up the editor in QlikCommunity (by either creating a new post or replying to a current thread (click the "Advanced Editor" in the top right of the reply window), click on the Insert button and choose Syntax Highlighting > Plain :

     

    insert-code-button.png

    Step 3: Paste your code into the shaded area:

     

    If you've done everything correctly to this point, your code should come out looking like this:

     

     

    LET vEndDate = num(YearEnd($(vTodaysDate)));
    LET NumberOfDays = num(YearEnd($(vTodaysDate))) - $(vStartDate) + 1;
    
    
    LinkTable:
    LOAD DISTINCT
     Year(Date) as Year,
     Month(Date) as Month,
     Date(MonthStart(Date), 'MMMYY') as MonthYear,
     if(monthstart(Date) <= $(vTodaysDate), 1, 0) as _History,
     'Q' & Ceil(Month(Date)/3) as Quarter,
     Dual('Q' & Ceil(Month(Date)/3) & '-' & Year(Date), Year(Date) & Ceil(Month(Date)/3)) as QtrYear,
     Week(Date) as Week,
     Weekstart(Date) as Weekstart,
     Weekend(Date) as Weekend
     ;
    Load
     Date($(vEndDate) - RecNo() +1) as Date
    AutoGenerate($(NumberOfDays)); 
    
    
    JOIN LOAD DISTINCT
     text([Customer Number]) as [Customer Number]
    FROM ..\Database\QVDs\Customers.qvd (qvd);
    
    
    JOIN LOAD DISTINCT
     [Address Number] as [Customer Number],
    //          Year(Makedate($(vCurrentYear) + [Year Offset])) as Year, 
     Year([Invoice Date]) as Year,
     [Sales Rep Number]
    RESIDENT Sales;
    //FROM
    //[..\Database\SalesReps Quota.xlsx]
    //(ooxml, embedded labels, table is [Monthly Quota]);
    
    
    DROP FIELD [Sales Rep Number] FROM Sales;
    
    
    
    
    LEFT JOIN LOAD
     MonthYear,
     [Customer Number],
     date(MonthYear) & '_' & [Customer Number] as BudgetKey,
     date(MonthYear) & '_' & [Customer Number] & '_' & [Sales Rep Number] as SalesKey,
     date(MonthYear) & '_' & [Sales Rep Number] as QuotaKey
    RESIDENT LinkTable;
    
    

     

     

    If you have any questions, please leave comments on this document or contact Sara Leslie for assistance.