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: 
nicolai_moller
Contributor
Contributor

change cell color based on value in previous cell

Hi

I'm trying to colorcode cells if the cell above changes. The table below consists of two events, where Event A is inserted on december 15 and changes (updates) State and/or Start 3 times. Everytime State or Start changes is should be colored and

EventChangelog DateChangelogStateStart
A15122013Insert1-
A01012014Update201012014
A01012014Update204012014
A10012014Update310012014
B01122013Insert102122013
B05122013Update402122013
B17122013Update302122013

The rows with Insert in them should never be colored as they have no previous status.

This is what I'm trying to achieve.

EventDateChangelogStateStart
A15122013Insert1-
A01012014Update201012014
A01012014Update204012014
A10012014Update310012014
B01122013Insert102122013
B05122013Update402122013
B17122013Update302122013

Do I use peek in this situation? Thanks

1 Solution

Accepted Solutions
Nicole-Smith

The attached should give you what you need.

I started by writing some load script to flag where there are State or Start changes:

Data:

LOAD Event, date#([Changelog Date],'DDMMYYYY') as [Changelog Date], Changelog, State, Start INLINE [

    Event, Changelog Date, Changelog, State, Start

    A, 15122013, Insert, 1, -

    A, 01012014, Update, 2, 01012014

    A, 01012014, Update, 2, 04012014

    A, 10012014, Update, 3, 10012014

    B, 01122013, Insert, 1, 02122013

    B, 05122013, Update, 4, 02122013

    B, 17122013, Update, 3, 02122013

];

LEFT JOIN (Data)

LOAD Event, [Changelog Date], Changelog, State, Start,

    if(Event = Previous(Event) and State <> Previous(State), 1, 0) as [State Change],

    if(Event = Previous(Event) and Start <> Previous(Start), 1, 0) as [Start Change]

RESIDENT Data

ORDER BY Event, [Changelog Date], Changelog, State, Start;

Then I used these fields in a straight table to determine what the background color should be:

View solution in original post

3 Replies
Not applicable

Use Set Analysis to conditionally color the cells.

Nicole-Smith

The attached should give you what you need.

I started by writing some load script to flag where there are State or Start changes:

Data:

LOAD Event, date#([Changelog Date],'DDMMYYYY') as [Changelog Date], Changelog, State, Start INLINE [

    Event, Changelog Date, Changelog, State, Start

    A, 15122013, Insert, 1, -

    A, 01012014, Update, 2, 01012014

    A, 01012014, Update, 2, 04012014

    A, 10012014, Update, 3, 10012014

    B, 01122013, Insert, 1, 02122013

    B, 05122013, Update, 4, 02122013

    B, 17122013, Update, 3, 02122013

];

LEFT JOIN (Data)

LOAD Event, [Changelog Date], Changelog, State, Start,

    if(Event = Previous(Event) and State <> Previous(State), 1, 0) as [State Change],

    if(Event = Previous(Event) and Start <> Previous(Start), 1, 0) as [Start Change]

RESIDENT Data

ORDER BY Event, [Changelog Date], Changelog, State, Start;

Then I used these fields in a straight table to determine what the background color should be:

Clever_Anjos
Employee
Employee

You don´t need peek in this situation.

You can use a straihght table and "Above" function to form a BackGround Color Expression