Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF statement on same value

I have the same Prog_Id as seen in the example below:

UKCountryProg_IdRatingDateProjection
UK1001/05/2014     1,401,000
UK54781111/10/2013    57,340,162
UK55391101/11/2013     9,103,812
UK55601125/09/2013    20,491,000
UK56341104/12/2013    27,411,600
UK5634804/12/2013     1,106,809
UK56571014/02/2014     6,476,215
UK56651026/03/2014    12,600,000
UK5665826/03/2014     2,140,016
UK56691009/05/2014    22,785,308

The difference is that it holds different rating values.

CountryProg_IdRatingDateProjection
UK5634 11 04/12/2013    27,411,600
UK5634 804/12/2013     1,106,809

So for example Prog_Id 5634 has the rating 11 and 8. But I want to filter this in the following manner:

If Prog_Id's are the same and IF the rating is > 10, then give me the projection value, IF NOT, give me blank.

4 Replies
Anonymous
Not applicable
Author

Keep Prog_Id in the dimension and

Try

If(rating>10,Projection,'')

Not applicable
Author

So how does this equation know and differentiate that the prog_id is the same?

Not applicable
Author

In this case you are not grouping on the Prog_id so it checks the condition for each row. Hence it will check only for the rating not for the prog_id.

maxgro
MVP
MVP

1.png

script

source:

load * inline [

UKCountry, Prog_Id, Rating, Date, Projection

UK, 5478, 10, 01/05/2014,    1401000

UK, 5478, 11, 11/10/2013,    57340162

UK, 5539, 11, 01/11/2013,    9103812

UK, 5560, 11, 25/09/2013,    20491000

UK, 5634, 11, 04/12/2013,    27411600

UK, 5634, 8, 04/12/2013,    1106809

UK, 5657, 10, 14/02/2014,    6476215

UK, 5665, 10, 26/03/2014,    12600000

UK, 5665, 8, 26/03/2014,    2140016

UK, 5669, 10, 09/05/2014,    22785308

];

left join (source) load

Prog_Id, count(Prog_Id) as cnt resident source group by Prog_Id;

result:

NoConcatenate load

  *,

  if(cnt = 1 or (cnt >1 and Peek(Prog_Id) <> Prog_Id and Rating > 10),1,0) as flg

Resident source

order by Prog_Id, Rating desc;