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

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

Comparing two rows data

Hi,

in a straight table I'd like to compare a row data with its year-previuos data.

Tha table contains a Year and an amount: the amount is calculates as Sum (prices).

I'd like to set the amount cells foreground color as red if the data of one year are less then the previous year ones, so I need a formula to set the background cells.

It should be something like this:

If (Sum(price)>Sum( <????> price), RBG(0,128,0),RGB(255,0,0))

Should anybody help me to set the right formula?

Thank you.

N.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can use the above() function get a value from the previous row in a table.

If (Sum(price)>above(Sum(price)), RBG(0,128,0),RGB(255,0,0))


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can use the above() function get a value from the previous row in a table.

If (Sum(price)>above(Sum(price)), RBG(0,128,0),RGB(255,0,0))


talk is cheap, supply exceeds demand
Not applicable
Author

Try something like below in the expression for background color:

if(sum(price) > above(aggr(sum(price),Year)),RGB(0,128,0),RGB(255,0,0))

Thanks,

Singh

Anonymous
Not applicable
Author

Sorry...i can't mark both your answers as "right answer", so i chose the first one.

Thank you to everybody 🙂

N.

Not applicable
Author

You chose the right one as correct.

Gysbert Wassenaar.. is from whom I am learning