Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if statement

The question is pretty simple, but I'm able to figure out how to resolve a problem I have.

Basically i'd like to sum a value when the following condition is valid:

sum (if (id = id - n, value))

where n is a number that allows me to go back nth position from the id.

I cannot use the previous statement because on the pivot table I can perform selections.

Thanks in advance for your recommendations.

Giulio

2 Replies
Or
MVP
MVP

I'm having a hard time understanding what exactly you want to achieve. Could you post a sample table / sample data of the desired result?

Not applicable
Author

I have uploaded a qv file as starting point, as my QV is huge.

The file contains:

1. a pivot table with the following:

- dimensions: campaign and cmp_counter_id (basically a rowno() on a sorted campaign field)

- fact (expression) n_app

2. a variable (that simulates another field I have, but for the example should be fine).

I'd like to add to this table, without using the above feature, another field, that sum the n_app of n:th-1 position before, in other words:

if n=1 then n-1=0 and for campaign 200809 i should see 8, for the next one 7, and so on.

if n=2 the n-1 =1 and for campaign 200809 i should see -, for the next one 8, and so forth.

I hope I've been able to explain better the problem I'm facing.

Thanks

Giulio