Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to check top row.

Hello. I want to check top row from csv data .

 

source data is like ;

 companyID | companyName| oppotunityID

      1 |    AAAA  |  12345

      1 |    AAAA  |  6789

      2 |    BBBB  |  11111

      2 |    BBBB  |  12346

      3 |    CC  |  22222

 

and requirement output like this;

flag |companyID | companyName| oppotunityID

  *  |    1 |    AAAA  |  12345

      |   1 |    AAAA  |  6789

  *  |    2 |    BBBB  |  11111

      |    2 |    BBBB  |  12346

  *   |    3 |    CC  |  22222

 

I want to mark the first line of data for each companyID.

How can we compare the data before and after a line?

 

Thank you.

 

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

@mhodent, as explained by @mkami input and output are csv files.

Use a tMap with the input connected to your input file and the output connected to the output file and each with the corresponding schema.
Declare 3 locale variables (in the middle of the tMap):
- currentId: connected to input flow companyID
- flag: enter the expression
(Var.previousId == null || !Var.previousId.equals(Var.currentId)) ? "*" : ""
- previousId: enter the expression
Var.currentId

As expressions are executed in the order they are defined, you can easily imagine the result.
Now connect output fields to the corresponding one from the input flow and connect the flag field to the variable Var.flag

View solution in original post

3 Replies
MartinD1
Contributor
Contributor

Hi mkami,

I'm using this SQL statement:

"select companyID, max(oppotunityID)
from company
group by companyID"

Mark in tMap  and in tDBOutput "Action on data" Update row with new flag.

 

MartinD

TRF
Champion II
Champion II

@mhodent, as explained by @mkami input and output are csv files.

Use a tMap with the input connected to your input file and the output connected to the output file and each with the corresponding schema.
Declare 3 locale variables (in the middle of the tMap):
- currentId: connected to input flow companyID
- flag: enter the expression
(Var.previousId == null || !Var.previousId.equals(Var.currentId)) ? "*" : ""
- previousId: enter the expression
Var.currentId

As expressions are executed in the order they are defined, you can easily imagine the result.
Now connect output fields to the corresponding one from the input flow and connect the flag field to the variable Var.flag
Anonymous
Not applicable
Author

@TRF

Exactly! Thank you ~ 0683p000009MACn.png I can get correctly data using tMap.

 

@mhodent

also, thanks for your comment 0683p000009MACn.png