Ta funkcja zwraca liczbę całkowitą reprezentującą sekundy, gdy ułamek expression jest interpretowany jako czas zgodnie ze standardową interpretacją liczb.
Składnia:
second (expression)
Typ zwracanych danych: integer
Kiedy używać
Funkcja second() jest przydatna, gdy chcesz porównać agregacje według sekundy. Za pomocą tej funkcji można na przykład sprawdzić rozkład liczb aktywności w ujęciu sekundowym.
Jeżeli nie podano inaczej, w przykładach w tym temacie stosowany jest następujący format daty: MM/DD/RRRR. Format daty jest określony w instrukcji SET DateFormat w skrypcie ładowania danych. Domyślny format daty w Twoim systemie może być inny ze względu na ustawienia regionalne i inne czynniki. Formaty zastosowane w przykładach można zmienić, aby dostosować je do własnych wymagań. Zamiast tego można też zmienić formaty w skrypcie ładowania, aby pasowały do tych przykładów. Więcej informacji można znaleźć w temacie Modyfikowanie ustawień regionalnych aplikacji.
Domyślne ustawienia regionalne w aplikacjach są oparte na profilu użytkownika. Te ustawienia regionalne nie są związane z językiem wyświetlanym w interfejsie użytkownika Qlik Cloud. Interfejs Qlik Cloud będzie wyświetlany w tym samym języku co używana przeglądarka.
Skrypt ładowania zawiera ten sam zestaw danych i scenariusz co w pierwszym przykładzie. Jednak w tym przykładzie do aplikacji został załadowany niezmieniony zbiór danych. Wartości second są obliczane przez miarę w obiekcie wykresu.
Załaduj dane i otwórz arkusz. Utwórz nową tabelę i dodaj to pole jako wymiar:date.
Utwórz następującą miarę:
=second(date)
Tabela wynikowa
date
=second(date)
01/01/2022 10:10:22 PM
22
01/02/2022 8:35:54 AM
54
01/03/2022 5:40:49 AM
49
01/03/2022 2:21:53 PM
53
01/04/2022 6:49:38 PM
38
01/05/2022 7:04:57 PM
57
01/05/2022 7:34:46 PM
46
01/06/2022 8:49:09 AM
9
01/06/2022 11:29:38 AM
38
01/06/2022 10:58:34 PM
34
Wartości dla second są tworzone za pomocą funkcji second() i przez przekazanie daty jako wyrażenia w mierze dla obiektu wykresu.
Przykład 3 — Scenariusz
Przegląd
Otwórz Edytor ładowania danych i poniżej dodaj skrypt ładowania do nowej karty.
Skrypt ładowania zawiera:
Zestaw danych znaczników czasu, który reprezentuje ruch do określonej strony internetowej sprzedaży biletów na festiwal. Te znaczniki i odpowiedni id zostają załadowane do tabeli o nazwie Web_Traffic.
Używana jest zmienna systemowa TimeStampM/D/YYYY h:mm:ss[.fff] TT.
W tym przypadku było 10000 biletów, które wystawiono na sprzedaż 20 maja 2021 r. o godz. 9:00. Minutę później bilety były wyprzedane.
Użytkownik chciałby otrzymać obiekt wykresu pokazujący liczbę wizyt w witrynie w ujęciu sekundowym.
Skrypt ładowania
SET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';
tmpTimeStampCreator:
load
makedate(2022,05,20) as date
AutoGenerate 1;
join load
maketime(9+floor(rand()*2),0,floor(rand()*59)) as time
autogenerate 10000;
Web_Traffic:
load
recno() as id,
timestamp(date + time) as timestamp
resident tmpTimeStampCreator;
drop table tmpTimeStampCreator;
Tabela wyników będzie wyglądać podobnie do poniższej tabeli, tylko będzie zawierała inne wartości dla miary agregacji:
Tabela wynikowa
second(timestamp)
=count(id)
0
150
1
184
2
163
3
178
4
179
5
158
6
177
7
169
8
149
9
186
10
169
11
179
12
186
13
182
14
180
15
153
16
191
17
203
18
158
19
159
20
163
Jeszcze 39 wierszy
Dimension
In Analytics Services:
A dimension is an entity used to categorize data in a chart. For example, the slices in a pie chart or the bars of a bar chart represent individual values in a dimension. Dimensions are often a single field with discrete values, but can also be calculated in an expression.
A dimension is a dataset in a data mart that forms part of the star schema. Dimension datasets hold the descriptive information for all related fields that are included in the fact table’s records. A few common examples of dimension datasets are Customer and Product. Since the data in a dimension dataset is often denormalized, dimension datasets have a large number of columns.
The load script is a sequence of statements that defines what data to load and how to link the different loaded tables. It can be generated with the Data manager, or with the Data load editor, where it also can be viewed and edited.
A field is a data asset containing values, loaded from a data source. At a basic level, a field corresponds to a column in a table. Fields are used to create dimensions and measures in visualizations.
Charts are objects where calculations, aggregations, and groupings can be made. Graphical visualizations, such as bar charts and pie charts are common examples, but also non-graphical objects such as pivot tables are charts.
A chart consists of dimensions and measures, where the measures are calculated once per dimensional value. If the chart contains multiple dimensions, the measures are calculated once per combination of dimensional values.
A dimension is an entity used to categorize data in a chart. For example, the slices in a pie chart or the bars of a bar chart represent individual values in a dimension. Dimensions are often a single field with discrete values, but can also be calculated in an expression.
A dimension is a dataset in a data mart that forms part of the star schema. Dimension datasets hold the descriptive information for all related fields that are included in the fact table’s records. A few common examples of dimension datasets are Customer and Product. Since the data in a dimension dataset is often denormalized, dimension datasets have a large number of columns.
The term dataset is usually synonymous with table. It can refer to the original source table, the table after undergoing transformations, or the fact and dimension tables in a data mart.
A preceding load is a script construct that allows you to load from the following LOAD or SELECT statement without specifying that source. Preceding loads are often faster than resident loads.
A measure is a calculation base on one ore more aggregations. For example, the sum of sales is a single aggregation, while the sum of sales divided by the count of customers is a measure based on two aggregations.
Sheets are components of Qlik Sense apps. They present visualizations to app users so they can explore, analyze, and discover data. Sheets can be public or private.
An aggregation is a calculation using multiple records in the source tables. Often it is a single field aggregated with a function such as sum, count, min, max, or average. For example, the sum of sales.