9. keep Function in Qlik Sense

3 min read 1 month ago
Published on Jul 30, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial explains how to use the Keep function in Qlik Sense, a powerful tool for managing data associations. You'll learn about the three primary types of Keep functions: Left Keep, Right Keep, and Inner Keep. Understanding these functions will help you manipulate data sets effectively and create more accurate analyses.

Step 1: Understanding the Keep Function

The Keep function in Qlik Sense allows you to control how data sets interact with one another. This is crucial for ensuring that your data model reflects the relationships you intend to analyze.

Key Concepts

  • Keep Function: Maintains associations between two tables without creating a new table.
  • Data Model: Represents how your data sets are connected.

Step 2: Using Left Keep

Left Keep keeps all records from the left table and only the matching records from the right table.

Steps to Implement Left Keep

  1. Load your left table. For example:
    LeftTable:
    LOAD * INLINE [
        ID, Name
        1, Alice
        2, Bob
        3, Charlie
    ];
    
  2. Load your right table:
    RightTable:
    LOAD * INLINE [
        ID, Score
        1, 90
        2, 80
    ];
    
  3. Apply the Left Keep function:
    LEFT KEEP (LeftTable, RightTable);
    
  4. Review your data model to ensure only the matching records from the right table are retained.

Practical Tips

  • Use Left Keep when you want to maintain all records from the primary data set while limiting associated data to relevant matches.

Step 3: Using Right Keep

Right Keep retains all records from the right table and only the matching records from the left table.

Steps to Implement Right Keep

  1. Ensure your right table is loaded as described in the previous section.
  2. Load your left table again if necessary.
  3. Apply the Right Keep function:
    RIGHT KEEP (LeftTable, RightTable);
    
  4. Check the data model to confirm that all records from the right table are present along with any relevant matches from the left.

Practical Tips

  • Right Keep is useful when you want to analyze all data from a secondary table while still linking it to relevant records in the primary table.

Step 4: Using Inner Keep

Inner Keep combines both tables but only retains records that have matches in both.

Steps to Implement Inner Keep

  1. Load both tables as before.
  2. Apply the Inner Keep function:
    INNER KEEP (LeftTable, RightTable);
    
  3. Examine your data model to ensure it only includes records with matches from both tables.

Practical Tips

  • Use Inner Keep when you need to focus strictly on the data that has relationships in both tables, which is helpful for strict data analysis scenarios.

Conclusion

In this tutorial, you learned about the Keep function in Qlik Sense and its three types: Left Keep, Right Keep, and Inner Keep. Each Keep function serves a specific purpose in managing data associations and can significantly impact your analysis.

Next Steps

  • Experiment with different Keep functions in your own Qlik Sense projects.
  • Consider how the Keep functions can help you create more accurate reports and dashboards based on your data relationships.