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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
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
marcohadiyanto
Partner - Specialist
Partner - Specialist

hi, if you want max month, why your month (-1) ?

syed_muzammil
Partner - Creator II
Partner - Creator II

Hi,

Can't you use just a date field instead of all this. I mean

Date={$(=Date(Max(Date)))}.

Not applicable
Author

Hi,

-1 is the default for max month

if you max month is Dec then -1 will show the month of "Dec" , when you mention -2 then it will show the previous month " Nov".

Please use the condition & check in your application.

Not applicable
Author

i used the below conditon, but its showing "0"

sum({$<Date={$(=Date(max(Date)))}>}Amount)

deepakk
Partner - Specialist III
Partner - Specialist III

Hi,

Create a MonthNum at script level

eg : Num(Month) as MonthNum

And use the below expression

Sum({$<Year = {$(=max(Year))}, MonthNum = {$(=month(max(MonthNum)-1))},Day = {$(=max(Day))}>} Amount)

I hope this helps....

Not applicable
Author

Hi Deepak,

Only for Month or i have to do it for year & day also.

Not applicable
Author

Hi deepak,

I used the below expression as per your instruction but its showing "0".

Sum({$<Year = {$(=max(Year))}, MonthNum = {$(=month(max(MonthNum)-1))},Day = {$(=max(Day))}>} Amount)

upto Month its showing correctly when i add "Day ={$(=max(Day))}" in the above expression then its showing the Amount "0"

deepakk
Partner - Specialist III
Partner - Specialist III

HI,

First Check out what Date your getting in Max(Year) & Max(MOnthNum) & Max(Day)...

if its 2010 10 1 then check if you have any Amount for that particular.

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

Also check the formatting of dates.

eg :

Day in backend would be 01 or 02 but when you say Max(Day) it might become 1 or 2.

Thia might also be the reason for 0 Amount.