Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression to compare to fields in a table

Hello,

I have a table with two fields ID1, ID2.

I’m looking for an expression to find all entries where ID1 <> ID2.

In the following inline, I would like to ‘earmark’ rows 3,17.

t:
load
RowNo() as RowId,
*
;
LOAD * INLINE [
ID1, ID2
1, 1
2, 2
3, 2
4, 4
5, 5
6, 6
7, 17
8, 8
9, 9
]
;

Thanks,

Shaul

1 Solution

Accepted Solutions
preminqlik
Specialist II
Specialist II

hi there,

use this expression in chart !

only({<ID1={'=ID1<>ID2'}>}ID2)

find the attachment

View solution in original post

12 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

t:
load
RowNo() as RowId,
*,

If(ID1 <> ID2, 1, 0) AS Flag
;
LOAD * INLINE [
ID1, ID2
1, 1
2, 2
3, 2
4, 4
5, 5
6, 6
7, 17
8, 8
9, 9
]
;


Now in set analysis you can use flag field to find count() or sum().


=Count({<Flag={1}>} ID1)


Hope this helps you.


Regards,

Jagan.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

To filter:

t:

load

  RowNo() as RowId,

  *

where ID1 <> ID2

;

LOAD * INLINE [

    ID1, ID2

    1, 1

    2, 2

    3, 2

    4, 4

    5, 5

    6, 6

    7, 17

    8, 8

    9, 9

];

To flag matches/mismatches:

t:

load

  RowNo() as RowId,

  *,

  If(ID1 = ID2, 1, 0) As MatchFlag

;

LOAD * INLINE [

    ID1, ID2

    1, 1

    2, 2

    3, 2

    4, 4

    5, 5

    6, 6

    7, 17

    8, 8

    9, 9

];

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
its_anandrjs

Hi,

Try this ways

load
RowNo() as RowId,
if(ID1=ID2,'Match Record','UnMatch Record') as IdDetails, //For Finding flag (Match and MisMatch)
if(ID1=ID2,1 , 0 ) as Flag //For SET analysis calculation
*;
LOAD * INLINE [
ID1, ID2
1, 1
2, 2
3, 2
4, 4
5, 5
6, 6
7, 17
8, 8
9, 9
]
;

Regards

Anand

Not applicable
Author

Thanks for the tip Jonathan. What I am looking for is a Chart/Expression solution as opposed to a Scripting one. I was wondering if it is doable to compare two columns in a  QV  chart. Thanks! Shaul

Not applicable
Author

Thanks for the tip Anand. What I am looking for is a Chart/Expression solution as opposed to a Scripting one. I was wondering if it is doable to compare two columns in a  QV  chart. Thanks! Shaul

Not applicable
Author

Thanks for the tip Jagan. What I am looking for is a Chart/Expression solution as opposed to a Scripting one. I was wondering if it is doable to compare two columns in a  QV  chart. Thanks! Shaul

Not applicable
Author

try

where not exists(ID1,ID2)

Not applicable
Author

ahhhh.

then in the chart write an expresson like this

=IF(ID1<>ID2, whateveryouwant2returniftheymatch)

notice that I didn't include else.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Wouldn't that just be an expression:

ID1 <> ID2

Or is it more complex than that?

-Rob