Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
What is the meaning of if(peek(CourseGroupName) <> CourseGroupName, 1, peek(CourseCount) + 1) as CourseCount
Thanks in advance.
Script code-
Courses:
LOAD
if(peek(CourseGroupName) <> CourseGroupName, 1, peek(CourseCount) + 1) as CourseCount,
*;
LOAD
RecNo() as CourseID,
Region & ': ' & Location & '-' & Course & '-' & month(Date) as CourseName,
Location & '-' & [Course Area] & '-' & month(Date) as CourseGroupName,
//Date,
date(Date) as StartDate,
date(Date + Days) as EndDate,
Month(Date) AS CourseMonth,
'Q' & ceil(month(Date)/3) as CourseQuarter,
Course,
[Course Area],
Location,
Region,
Status,
Days
peek(CourseGroupName) <> CourseGroupName is evaluated. That means, it checks if CourseGroupName is different from the value in the previous row.
If it is different, CourseCount is set to 1.
If it is the same, CourseCount is set to previous row's CourseCount value + 1 (peek(CourseCount) + 1).
peek(CourseGroupName) <> CourseGroupName is evaluated. That means, it checks if CourseGroupName is different from the value in the previous row.
If it is different, CourseCount is set to 1.
If it is the same, CourseCount is set to previous row's CourseCount value + 1 (peek(CourseCount) + 1).
Hi,
peek(fieldname [ , row [ , tablename ] ] )
Returns the contents of the fieldname in the record specified by row in the internal table tablename. Data are fetched from the associative QlikView database.
Fieldname must be given as a string (e.g. a quoted literal).
Row must be an integer. 0 denotes the first record, 1 the second and so on. Negative numbers indicate order from the end of the table. -1 denotes the last record read.
If no row is stated, -1 is assumed.
Tablename is a table label, see Table Labels, without the ending colon. If no tablename is stated, the current table is assumed. If used outside the load statement or referring to another table, the tablename must be included.
Examples:
peek( 'Sales' )
returns the value of Sales in the previous record read ( equivalent to previous(Sales) ).
peek( 'Sales', 2 )
returns the value of Sales from the third record read from the current internal table.
peek( 'Sales', -2 )
returns the value of Sales from the second last record read into the current internal table.
peek( 'Sales', 0, 'Tab1' )
returns the value of Sales from the first record read into the input table labeled Tab1.
Load A, B, numsum( B, peek( 'Bsum' ) ) as Bsum...;
creates an accumulation of B in Bsum.