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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
niranjan_capgemnini
Contributor
Contributor

How to display max month sales

Hi experts,

  I struck in one place , my requirement is chart has to be display max month sales that some time current month sales is zero then it has to be displayed previous month sales.

if the previous month and current month sales is zero  then it has to be displayed last to last month sales like that it has to be show.

 

please guide me how to do this .

below formula i am using 

if((sum({<Year = {'$(=max(Year))'},[Month]={'$(=max([Month]))'},Status={'F'}>}Stock))=0,

sum({$<Year = {'$(=max(Year))'},Status={'F'}>}Stock),

sum({$<Year = {'$(=max(Year))'},[Month]={'$(=max([Month]))'},Status={'F'}>}Stock)

)

 

thanks in advanced 

Labels (1)
11 Replies
vikasmahajan

if your data model has MonthYear field try :

sum({$<MonthYear={"$(=Date(Max(MonthYear),'MMM-YY'))"},Status={'F'}>} Stock )

 

HTH

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
tresesco
MVP
MVP

Niranjan,

Your approach to expression might not give you expected result even for when maximum month has data. And that is simply because max year might not have data for max month always. To explain better, - max(month) would possibly always be 12/Dec. However for max/current  year you might not have data for Dec. That means, when you calculate max month - either calculate taking into consideration the fact that - that should be from max year that has data, or calculate month using Date field instead where data is there. If you consider 'when data is there'  i.e. in set analysis '=Sum(Stock)>0' your max month/date would itself take care of max month/prev month to max month or so.

 

Hope this helps.

niranjan_capgemnini
Contributor
Contributor
Author

Hi vikashmahaja,

 Thanks for replay. 

There is year and month is different fields, i concatenated fields in backend i tried it is not working.

Thanks

niranjan_capgemnini
Contributor
Contributor
Author

Hi Tresesco,
thanks for replay Tresesco,
i agree with you but here there is another requirement also included if user select at a time jan and Feb then user expectation only feb month stock. thats why i wrote the above calculated field. but if the max month sales is not there is not showing any thing .

please give me some ideas.

Thanks in advance........
tresesco
MVP
MVP

@niranjan_capgemnini wrote:

..if user select at a time jan and Feb then user expectation only feb month stock.
thats why i wrote the above calculated field...

Sorry, I could not follow or did not find  that this could result in an expression you wrote.  Could you share a sample app to work on?

niranjan_capgemnini
Contributor
Contributor
Author

Hi Tresesco,
i have attached sample QVF file please find the same at very first post.

Thanks in advanced .
please give some guide.
tresesco
MVP
MVP

Your month field is a text field. Max() would not work there. Try to fix the data at the script and then try to share with an elaboration of expected output..
niranjan_capgemnini
Contributor
Contributor
Author

Hi Tresesco,
i have modified the data , i have attached same please find the application
my expectation like below.
like India - 55
Lanka - 444

Thanks in advance.
please give me any one suggestion.
niranjan_capgemnini
Contributor
Contributor
Author

Hi Tresesco,
Any suggestion .

Thanks in advance...