Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
KrisF
Contributor II
Contributor II

Min value issue with Aggr function

I have the following input:
obs dDate value
195588 2024-02-21 13,43
194798 2024-02-20 13,55
192428 2024-02-15 13,41
191638 2024-02-14 13,31
190848 2024-02-13 13,23
190058 2024-02-12 13,81
172597 2024-01-11 14,26
170209 2024-01-08 14,62
39596 2023-05-17 13,85
38775 2023-05-16 13,78
37954 2023-05-15 13,64
37133 2023-05-12 13,34
36312 2023-05-11 13,38
35491 2023-05-10 13,44

I use this aggregate function:
=max( aggr(NODISTINCT if(min(total value,Year) = min(value), obs,0), (Year,(NUMERIC, DESCENDING)), (dDate,(NUMERIC, DESCENDING))))

I try to get the 'obs' for each year related to the lowest value of 'value'.
the formula above delivers the correct value (190848), but only for the year=2024.
The value for the previous years delivers a zero.

What is the correct way to solve this issue?

Labels (1)
1 Solution

Accepted Solutions
BrunPierre
Partner - Master
Partner - Master

Perhaps

=Only(If(Aggr(NODISTINCT Min(value), Year) = value, obs))

View solution in original post

6 Replies
LRuCelver
Partner - Creator III
Partner - Creator III

FirstSortedValue(obs, value)

This expression will always select the obs value associated with the smallest value regardless of what dimensions your chart has.

Dataintellinalytics

PFA, snapshot.

Aggr(FirstSortedValue(obs,value),Year)  should give you results for both the years, but because of load order you will see OBS value being displayed in different row.

KrisF
Contributor II
Contributor II
Author

Both options do not work, not in the separate straight table where the statistics are exposed, also not in the straight table where the data is located.

KrisF
Contributor II
Contributor II
Author

In the attached picture I made an example to illustrate the intention.

In dark yellow I marked the values that go wrong

BrunPierre
Partner - Master
Partner - Master

Perhaps

=Only(If(Aggr(NODISTINCT Min(value), Year) = value, obs))

KrisF
Contributor II
Contributor II
Author

Yes,I've got the expected results, thank you