Skip to main content Skip to complementary content

Sample

The sample prefix to a LOAD or SELECT statement is used for loading a random sample of records from the data source.

Syntax:  

Sample  p ( loadstatement | selectstatement )

The expression that is evaluated does not define the percentage of records from the dataset that will be loaded into the Qlik Sense application, but the probability of each record that is read to be loaded into the application. In other words, specifying a value p = 0.5 does not mean that 50% of the total number of records will be loaded, but instead that for each record there will be a 50% chance that it is loaded into the Qlik Sense application.

Arguments
Argument Description
p

An arbitrary expression which valuates to a number larger than 0 and lower or equal to 1. The number indicates the probability for a given record to be read.

All records will be read but only some of them will be loaded into Qlik Sense.

When to use it

Sample is useful when you would like to sample data coming from a large table, to understand the nature of data, distribution or field contents. As it brings a subset of data, the data loads are faster, allowing faster testing of scripts. Unlike First, the Sample function brings data from the whole table, instead of being limited to the first few rows. This can provide a more accurate representation of the data in some cases.

The following examples show two possible uses of the Sample script prefix:

Sample 0.15 SQL SELECT * from Longtable;

Sample(0.15) LOAD * from Longtab.csv;

Regional settings

Unless otherwise specified, the examples in this topic use the following date format: MM/DD/YYYY. The date format is specified in the SET DateFormat statement in your data load script. The default date formatting may be different in your system, due to your regional settings and other factors. You can change the formats in the examples below to suit your requirements. Or you can change the formats in your load script to match these examples.

Default regional settings in apps are based on the regional system settings of the computer or server where Qlik Sense is installed. If the Qlik Sense server you are accessing is set to Sweden, the Data load editor will use Swedish regional settings for dates, time, and currency. These regional format settings are not related to the language displayed in the Qlik Sense user interface. Qlik Sense will be displayed in the same language as the browser you are using.

Example 1 – Sample from an inline table

Example 2 – Sample from an autogenerated table

Learn more

 

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!