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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

get min Year with set analysis

Hi everyone,

I'm wrestling with this problem: I've defined a market with set analysis and I want to get the min Year where sum(Amount) > 0 as a variable. Does anyone know how I would do this?

So my set analysis looks like:

sum({<Company=,Location={'$(vLocation)'}>}Amount)

I thought I would do something like this:

FirstSortedValue(Year,aggr(if(sum({<Company=,Location={'$(vLocation)'}>}Amount)>0,1,0),Year))

But for some reason, the above expression returned an incorrect year.

Is this expression correct or are there other ways?

Thanks.

1 Solution

Accepted Solutions
Not applicable
Author

I believe I got it to work with the following:

=Min(if(aggr(SUM({<Company, Location = {'$(vLocation)'}>}Amount),Year)>0,Year),Year)

View solution in original post

7 Replies
sunny_talwar

May be this:

Min({<Year = {"=Sum({<Company, Location = {'$(vLocation)'}>} Amount) > 0"}>}Year)

MindaugasBacius
Partner - Specialist III
Partner - Specialist III

=sum(

{$<

  Location = {"=sum({1<Location = {$(vLocation)}>}Amount)>0"}

  ,Company =

>}

Amount)

The vLocation variable:

=Concat({$<Location = {'Location1*'}>}Location, ', ')

The result:

Screenshot_3.png

The example is attached.

UPDATE: sorry, misunderstood the issue.

Not applicable
Author

This didn't seem to work, but thank you for replying

sunny_talwar

Did it give anything? or did you get an error in syntax? Would you be able to provide a sample with expected output?

Not applicable
Author

I believe I got it to work with the following:

=Min(if(aggr(SUM({<Company, Location = {'$(vLocation)'}>}Amount),Year)>0,Year),Year)

Not applicable
Author

The text object gave me a ' - ' . I think I have a solution now

Anonymous
Not applicable
Author

Hi

Is it like ..

   if(Aggr(sum({<Company=,Location={'$(vLocation)'}>}Amount)>0,Min(year))