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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
tinkerz1
Creator II
Creator II

How to remove duplicate lines from AGGR

Hi,

I am using the AGGR function to group on selected items but I am getting duplications on rows, how can I use AGGR to group on a date range, max() and a particular field item?

The code below is intended to bring back the MAX download Month Year Item per date range and where the issue is closed.

But I get 2 rows returned.

The data is uploaded once a month and will have duplicate IDs but the status will change according the status of the issue.

Thanks,

=aggr(max([Download Month-Year Item]) and [Issue - Status]='Closed' and date([Issue - Closed Date])>=addmonths(date(vMEEndate),-12),[Issue - ID],[Issue - Closed Date])

 

   

Issue - Location L2Issue - IDIssue - Closed DateIssue - OwnerIssue - StatusDownload Month-Year ItemMax Download Month Year Item
Europe116-Dec-15Mr AClosed01-Feb-16-1
Europe116-Dec-15Mr AClosed01-Dec-15-1
Europe230-Sep-15Mr BClosed01-Nov-15-1
Europe230-Sep-15Mr BClosed01-Sep-15-1

 

4 Replies
Chanty4u
MVP
MVP

=aggr(Distinct max([Download Month-Year Item]) and [Issue - Status]='Closed' and date([Issue - Closed Date])>=addmonths(date(vMEEndate),-12),[Issue - ID],[Issue - Closed Date])


or


aggr(max([Download Month-Year Item]) and    Distinct [Issue - Status]='Closed' and date([Issue - Closed Date])>=addmonths(date(vMEEndate),-12),[Issue - ID],[Issue - Closed Date])

sunny_talwar

I am not completely sure I understand what you are trying to do. Do you have a sample you can share?

hic
Former Employee
Former Employee

You use

   aggr(

      max([Download Month-Year Item]) and

         [Issue - Status]='Closed' and

         date([Issue - Closed Date])>=addmonths(date(vMEEndate),-12),

      [Issue - ID],

      [Issue - Closed Date]

       )

The first parameter of the Aggr should be an aggregation, but you instead have a Boolean expression that only will return -1 or 0. Further, since you use naked field references, you may get undesired results.

Secondly, you say that you want one value per DateRange. But your Aggr() has both [Issue - ID] and [Issue - Closed Date] as dimensions. Then you will get one value per combination of these two, i.e. several per DateRange.

Thirdly, you have not wrapped the Aggr in an aggregation function. You should probably use a chart with DateRange as dimension and Max(Aggr(...)) as measure.

See also

Pitfalls of the Aggr function

Use Aggregation Functions!

HIC

swuehl
MVP
MVP

Try

Max(

{<  [Issue - Status]={'Closed'}, [Issue - Closed Date] = {">=$(=Date(addmonths(vMEEndate,-12),'DD-MMM-YY'))"}>}[Download Month-Year Item])

as expression in your chart with dimension Download MonthYear item removed.