Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

pascos88
Contributor

set analysis doesn't work well

Hi all,

I have some problems with this set analysis:

max({$<CampaignYear={"$(=Max(CampaignYear)-1)"}>}Score)

I attached the file output, I don't get why I cannot see the data from  the previews year..

Thanks for any helps

1 Solution

Accepted Solutions
colinh
Contributor II

Re: set analysis doesn't work well

Your set analysis is basically saying "show the max score where Year = 2017".

To achieve what you want you need to use the above() function.  This blog post should help:  The Above Function

10 Replies
colinh
Contributor II

Re: set analysis doesn't work well

Your set analysis is basically saying "show the max score where Year = 2017".

To achieve what you want you need to use the above() function.  This blog post should help:  The Above Function

YoussefBelloum
Esteemed Contributor

Re: set analysis doesn't work well

Hi

I think it is working well because your max year = 2018.. so max year -1 = 2017 and data is populated for 2017

sureshqv
Esteemed Contributor III

Re: set analysis doesn't work well

Hi.

try this

Sum({$<CampaignYear={"$(=Max(CampaignYear)-1)"}>}Score)

pascos88
Contributor

Re: set analysis doesn't work well

Thanks for your answer..

So I would populate that for all rows...

How I should write it?

any idea?

pascos88
Contributor

Re: set analysis doesn't work well

it doesn't work, I achieve the some results..just populate for 2017

thi_pham
Contributor

Re: set analysis doesn't work well

The max(CampaignYear) always return 2018, then it just populate for 2017.

I think you should check Above() function as colinh mentioned above.

  Above(max(score))

pascos88
Contributor

Re: set analysis doesn't work well

Hi I don't think that Above could be a solution, because the table that you can see in the picture, is a filtered table.

I needed maybe just to change the set expression and not populate the max score for just 2017 (max Year -1), but for all of them.

colinh
Contributor II

Re: set analysis doesn't work well

That would just give you the same as max(Score).  If you want to show the value from a different row, e.g., the 2017 value on the 2018 row, then you'll need to use an inter-record function such as above().  Alternatively you could do it in your load script using peek() or previous(), or by creating a table with Year-1 as a dimension and then joining that to your original table.

thi_pham
Contributor

Re: set analysis doesn't work well

I agree with you. An easiest way is to add a new dummy calculation column in data load namely Previous_Campaigned_Year= Campaigned_Year - 1

then make the set analysis like:

    max( {<CampaignYear= P(Previous_Campaigned_Year) >}  Score)