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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need max year, max month and max day using set analysis

Dear All,

i need to show max year, max month & max day of sales, so i used following function , but its not showing the amount of sales.
Pls see below function.
=Sum({$<Year = {$(=max(Year))}, Month = {$(=month(addmonths(max(Month) , -1)))},Day = {$(=max(Day))}>} Amount)


Regards,
Antony.


23 Replies
Not applicable
Author

Hi Deepak,

I checked both the condition which you mentioned on above , its fine.

When i use the below condition then its showing the correct Amount for max year, month & date.

=sum(if(Date=DateMax,Amount))

Also one more query.

The following expressions are same or different, Because i'm getting different amount for below expressions.

1) =sum({$<Year={$(=max(Year))}>} Amount)

2) = sum(if(Year=yMax,Amount))

deepakk
Partner - Specialist III
Partner - Specialist III

Hi,

Logically both should display same value if yMax = Max(Year),

If in variable yMax you have to specify "=". If you miss it , it might cause a problem.

Not applicable
Author

I have not missed , i used "=" sign for below variable.

yMax = max(Year)

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

I made a sample test file and tested both the expression and its showing me same value.

Can you attach you application so that we can test it out.

Not applicable
Author

Hi Deepak,

PFA.

Regards,

Antony

deepakk
Partner - Specialist III
Partner - Specialist III

Its little weird. Its working fine in my case.

Anyways I always prefer set analysis over If statement and the Set analysis part in your application working fine.

Best of Luck...

Not applicable
Author

Hi,

Have you found Answer for max year, max month & max day using set analysis.

deepakk
Partner - Specialist III
Partner - Specialist III

I got it .... I got it...... I got it.... Cool

In you case the value is coming zero because the Max(Day) is coming as 31. so the maximum date becomes 31-dec-2010 and you have data only till 3rd Dec.

so use below expression

sum({$<Year = {$(=max(Year))},MonthNum = {$(=max(MonthNum))},Day = {$(= Day(max(Date(Date,'DD/MM/YYYY'))))}>}Amount)

For the if problem you have to use the if statement in below manner.

if(max(Year)=yMax,Sum(Amount))

I hope this will close the issue

Not applicable
Author

Hi Deepak,

Can i have your mail id pls.

deepakk
Partner - Specialist III
Partner - Specialist III

kurup.d@gmail.com