Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Calculating Values from a "Preset Week" to the "Max Week"

Hi all,

i need some help....

I would like to calculate ,e.g. by selecting the "WEEK" field  from 1 to last one :

1) The result of MARGIN% from Week 1 to Max(WEEK)

2) The result of MARGIN% from Week 1 to Max(WEEK)-1)

3) The Difference between these 2 values.

In other words:

If i select the first  5 weeks of the year 2015 , i would like to obtain something like that:

-----------------------------------------------------------------------------------------------------------

if

MARGIN% (between Week 1 and week 5) 

<

MARGIN% (between Week 1 and week 4), 'ALERT','OK')

-----------------------------------------------------------------------------------------------------------

i can't figure out....

Thanks

Mark

1 Solution

Accepted Solutions

Re: Calculating Values from a "Preset Week" to the "Max Week"

Try something like this:

if(avg({< Week = {"<=$(=max(Week))"}>} MARGIN%) <

   avg({< Week = {"<=$(=max(Week)-1)"}>} MARGIN%), 'ALERT','OK')

with a selection on year=2015.

- Marcus

2 Replies

Re: Calculating Values from a "Preset Week" to the "Max Week"

Try something like this:

if(avg({< Week = {"<=$(=max(Week))"}>} MARGIN%) <

   avg({< Week = {"<=$(=max(Week)-1)"}>} MARGIN%), 'ALERT','OK')

with a selection on year=2015.

- Marcus

elena888
Valued Contributor

Re: Calculating Values from a "Preset Week" to the "Max Week"

Hi,

try to see if the attached qvw can help you: your logic is in the pink text box (I used two variables).

Let me know!

BR

Elena

Community Browser