Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to compare a single value dimension with aggr()

HI,

I need to find the latest product which is identified as the max product id group by season and Usage

I am able to get the latest product by  Aggr(Max([product ID]),[Season],[Usage] ).

Now when printing the data on a table I need to identify the  latest  product so I define a dimension as

if ([product ID] = (Aggr(Max([product ID]),[Season],[Usage] ))),'True','False').

However, this always prints false even when values for the product ID and agggr(--) are the same.


Please see below the o/p for ref

Product IDLatest?=(Aggr(Max([Product ID]),[Season ],[Usage] ))
66319200False96517654
70059823False96517654
79841275False96517654
79841838False96517654
62691415False96517654
96517654False96517654

Appreciate your help.

Thanks,

Ravi

1 Solution

Accepted Solutions
andrey_krylov
Specialist
Specialist

Hi Ravi, try to use TOTAL  aggrigation

if ([product ID] = Max(TOTAL <[Season],[Usage]> [product ID]) ,'True','False')


View solution in original post

7 Replies
swuehl
MVP
MVP

Are you using this in a dimension or expression of your chart? Any other dimensions in your chart context?

andrey_krylov
Specialist
Specialist

Hi Ravi, try to use TOTAL  aggrigation

if ([product ID] = Max(TOTAL <[Season],[Usage]> [product ID]) ,'True','False')


Anonymous
Not applicable
Author

Hi Stefan,

Yes, I have a bunch of other dimensions and measures coming from different related tables (qvd files).

Thanks,

Ravi

Anonymous
Not applicable
Author

Thank you so much, Andrey!

This definitely works but I am unable to use it as Dimension. I had to add that as a measure.

However, I have this filed in my filter and  I don't think we can add a measure to a filter.

Is there a workaround for that. Appreciate your help!

Thanks,

Ravi

swuehl
MVP
MVP

What if you use this as calculated dimension:

= Aggr( If([product ID] = Max(TOTAL<Season, Usage> [product ID]), 'True','False'), Season, Usage, [product ID])

Anonymous
Not applicable
Author

I tried but it is not working as desired. I am going to skip the filter part.

Thanks,

Ravi

itsik85
Contributor
Contributor

Worked great for me! Just need some help with this formula when ignoring some field, i.e Dim1.

= Aggr( If([product ID] = Max(TOTAL <Season, Usage> {<Dim1=>} [product ID]), 'True','False'), Season, Usage, [product ID]) not working...