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 used the below expression which you gave me but its not showing the amount.

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

upto month its showing the amount correctly when i add day(Day = {$(= Day(max(Date(Date,'DD/MM/YYYY'))))}) in above expression then its showing "0".

Have you used the above expression in my application ???

Regards,

Antony.

deepakk
Partner - Specialist III
Partner - Specialist III

create a text object and check what you are getting in the below expression

Day(max(Date(Date,'DD/MM/YYYY'))).

Compare the value with the Day field . Also check if you have any data for that particular date

marcohadiyanto
Partner - Specialist
Partner - Specialist

hi,,

i already try set analysis from antony, the result shown 0 too..

how can i get max day?

jonathandienst
Partner - Champion III
Partner - Champion III

Anthony

Assuming that you have more than one year's data in the system, remember that the month clause works across the entire data set, so Max(Month) will be December. With your add months, that will return November. Max (Year) will be 2011. Therefore your set statement will attempt to return data for 31 November 2011. Apart from being an invalid date, you presumably have no data for that date.

But if you are looking for sales on the last day of the previous month, you would probably do better with something like:

=Sum({$<Date= {$(=MonthStart(max(Date)) - 1)}>} Amount)

Hope that helps
Jonathan


Logic will get you from a to b. Imagination will take you everywhere. - A Einstein