Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
joshm43
Contributor III
Contributor III

How can I compare a dimension value between current and prior row?

I am working on a table where I need to be able to compare the value for a record ID from the current row to the record ID from the prior row.  I have researched somewhat, but have not been able to determine how to accomplish this.  A simple example is:

Row 1 - Record ID is '1A4B8C'

Row 2 - Record ID is '1A4B16C'

Row 3 - Record ID is '1A4B16C'

So the first test comparing Row 2 back to Row 1 would need to show False, while the second test comparing Row 3 to Row 2 would show True.  I am working with A/N fields and need to work on the table sort order.

I have looked at ABOVE() but it appears to be for counts rather than a straight match.

Any help is appreciated.  Thanks, Mitch

Labels (1)
1 Solution

Accepted Solutions
_ylc
Partner - Creator
Partner - Creator

can you try if this works:

if(below(total ID)=ID, 'True','False')

View solution in original post

6 Replies
_ylc
Partner - Creator
Partner - Creator

Are you working this on script level or on front end?

This can be done on the script level. What you need to use is the function Previous().

You can create a logic in the script, if(Previous(ID)=ID, 'True', 'False'). Since you are comparing from bottom to top, you need to order by the table in descending.

joshm43
Contributor III
Contributor III
Author

Unfortunately, I am working on the front end and do not have access to the script, so the solution needs to be one that can be used in an expression.  Thanks for the suggestion!

_ylc
Partner - Creator
Partner - Creator

can you try if this works:

if(below(total ID)=ID, 'True','False')

joshm43
Contributor III
Contributor III
Author

Thanks.  I tried both using Above and Below.  The "Total" qualifier seems to make the difference.  However, it will only work as a Measure; when I try as a Dimension, I get an "Invalid Dimension" error.  Ideally, I would like to suppress the row using this condition when false.  This is a great lead, let me take it an run with it a bit. 🙂

_ylc
Partner - Creator
Partner - Creator

that is quite a challenge. if you want it as a dimension, best to create it in script level.

joshm43
Contributor III
Contributor III
Author

Thanks for the information.  I may just have to live with it as is and accept the redundancy on the report.  I will be able to use this in the graphical (numeric) visualizations, so thanks again!