Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
DarioDella
Contributor
Contributor

If function doesn't work

Hi, i'm newbie in Qlik sense: my df has this structure

id| date1| date2|date3|date4|version|who_change|

AA| 20-02-2022| 21-02-2022|21-02-2022| -| 1| X|

AA| 20-02-2022| 22-02-2022|-| 22-02-2022| 2| Y|

AA| 20-02-2022| 24-02-2022|24-02-2022| 22-02-2022| 3| X|

if date2 = date3 who_changer is X

if date2 = date4 who_change is Y

my goal is create a new table (front-end) with this structure

id| date1| date2|delay|n_change|who_change_last|who_change_last_2|

AA|20-02-2022|23-02-2022|4|3|X|Y|

i tried something like this on who_change_last:

aggr(
if (GetSelectedCount (version) = $(=$(=$(maxversion))), who_change, only ( {<version= {$(=$(=$(maxversion)))}>} who_change))
, ID)

where  maxversion = max(version)

i tried something like this on who_change_last2:

aggr(
if (GetSelectedCount (version) = $(=$(=$(maxversion2))), who_change, only ( {<version= {$(=$(=$(maxversion2)))}>} who_change))
, ID)

where  maxversion2 = max(version,2)

the problem is that: when id is selected all works, when is not selected doesn't work.

How can i fix it? Thanks all for any tips.

 

Labels (1)
2 Replies
Mark_Little
Luminary
Luminary

HI @DarioDella 

I think it would help if you explained what you are trying to do, the Set Analysis does not look correct, but without understanding the use case it is hard to explain how to correct it. For One you shound not need to use =$ over and over. Also not sure why you would use a getselectedcount in a Aggr function.

MN2
Contributor III
Contributor III

Hi DarioDella,

I advise you to do as many calculations as possible in the script.

You can create new columns in the data load script to add that information.

You can't use an aggr function in the script, but if you know a little bit sql you should be able to calculate the information you want by doing some group by. In qlik langage you can also use if, max, group by...etc

MN