Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Checking number of weeks in specific status

Hello,

We have a simple project structure with a column which shows the status of this project.

There is a need to add a column which will show for how many weeks project was saved under specific status.

Example table:

Project WeekFlagNumber of weeks not in green
A15W1White0
A15W2Green0
A15W3Yellow1
A15W4Yellow2
A15W5Red3
A15W6Green0
B15W4Red1
B15W5Green0
B15W6Red1
C15W5Green0
C15W6Green0

Column 4 is representing expected outcome in QlikView which I am not able to achieve.

Calculation should basically work like that:

- If status for week is green, show zero (green always resets the count)

- If status for week is red, yellow, and was green previous week, show 1

- If status for week is red, yellow, and was red / yellow previous week show value at previous week + 1

I would be very grateful for any suggestion about how to code this.

BR,

Kuba

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Create the count in script like:

LOAD

  ...

  Project,

  Week,

  Flag,

  If(Flag = 'Green', 0, If(Previous(Flag)) = 'Green', 1, Peek(WeeksNotInGreen) + 1) As WeeksNotInGreen,

  ...

HTH

Jonathan

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

View solution in original post

5 Replies
rubenmarin

Hi Kuba, If the counting column is called Weeks you can use:

If(Flag='Green' or Flag='White', 0, Above(TOTAL [Weeks]+1))

maxgro
MVP
MVP

maybe it helps

- dimensions are yellow

- expression (calcexp) is

if(Flag='Green',0,

     if(match(Flag,'Red','Yellow') and match(Above(TOTAL Flag), 'Green'),1,

     if(match(Flag,'Red','Yellow') and match(Above(TOTAL Flag), 'Red','Yellow'), rangesum(above(total      column(1),1,1))+1,

     ''

)))

1.jpg

Not applicable
Author

Hello Ruben,

Thank you for your time spend on this!

Your solution works fine in this specific pivot table. Sorry for not mentioning this before but I was thinking on calculating this using data load. Do you have any idea how can it be done?

BR,

Kuba

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Create the count in script like:

LOAD

  ...

  Project,

  Week,

  Flag,

  If(Flag = 'Green', 0, If(Previous(Flag)) = 'Green', 1, Peek(WeeksNotInGreen) + 1) As WeeksNotInGreen,

  ...

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thank you Jonathan, that is exactly what i needed