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: 
Not applicable

Max Sales

Hi friends,

I have some sales value interval wise,my requirement is to find max sales value for the selected interval,and if no interval is selected then the text box show max sales value from all interval,anyone please help me out.

I have attached a sample app

regards

bhawna   

1 Solution

Accepted Solutions
tresesco
MVP
MVP

='Max Sales'&chr(10)&

If( Not GetSelectedCount(Interval),  RangeMax(Max([0-1 month]),Max([2-3 month]),Max([5-6 month])),

  if(Interval='0-1 month',max([0-1 month]),if(Interval='2-3 month',max([2-3 month]),if(Interval='5-6 month',max([5-6 month]))))

)

PFA

View solution in original post

10 Replies
anbu1984
Master III
Master III

Try this expr

='Max Sales'&chr(10)&if(Interval='0-1 month',sum([0-1 month]),if(Interval='2-3 month',sum([2-3 month]),if(Interval='5-6 month',sum([5-6 month]),

(If(sum([0-1 month])>sum([2-3 month]),If(sum([0-1 month])>sum([5-6 month]),sum([0-1 month]),sum([5-6 month])),sum([2-3 month]))

))))

geert_gelade
Creator
Creator

A possible solution is to change the script to:

Sales:

load * inline [

Project, 0-1 month,2-3 month,5-6 month

P1,10,20,30

P2,80,50,20

P3,10,5,20

P4,60,10,10

];

SalesFinal:

CrossTable(Interval,Sales)

load *

resident Sales

Put list box for Interval and in the text box "='Max Sales = ' & chr(10)&max(Sales)"

Not applicable
Author

Hi,

Is that Datamodel fixed? I mean, everything would be easier like:

* inline [

Project, Fact, Interval
P1,10,0-1 month
P1,20,2-3 month
P1,30,5-6 month
P2,80,0-1 month
P2,50,2-3 month
P2,20,5-6 month
P3,10,0-1 month
P3,5,2-3 month
P3,20,5-6 month
P4,60,0-1 month
P4,10,2-3 month
P4,10,5-6 month
]
;



Load * inline [
Interval
0-1 month
2-3 month
5-6 month
]
;

Not applicable
Author

I cant make changes in data model

geert_gelade
Creator
Creator

That's what I tried to accomplish with the crosstable-load.

tresesco
MVP
MVP

='Max Sales'&chr(10)&

If( Not GetSelectedCount(Interval),  RangeMax(Max([0-1 month]),Max([2-3 month]),Max([5-6 month])),

  if(Interval='0-1 month',max([0-1 month]),if(Interval='2-3 month',max([2-3 month]),if(Interval='5-6 month',max([5-6 month]))))

)

PFA

Not applicable
Author

Thank you all

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi Bhawna,

I know your question have been answered, however if you wish to take the Max from Project perspective.

So say you select either P1.....P4 from Project list, what is the Max:-

This expression code answer that question

='Max Range For Project'& Chr(10)&

if(not GetSelectedCount(Project),RangeMax(Max([0-1 month]),Max([2-3 month]),Max([5-6 month])),

    if(Project='P1',RangeMax(Max([0-1 month]),Max([2-3 month]),Max([5-6 month])),

        if(Project='P2',RangeMax(Max([0-1 month]),Max([2-3 month]),Max([5-6 month])),

            if(Project='P3',RangeMax(Max([0-1 month]),Max([2-3 month]),Max([5-6 month])),

                IF(Project='P4',RangeMax(Max([0-1 month]),Max([2-3 month]),Max([5-6 month])))))))

Best Regards,

Gabriel

Not applicable
Author

but if I select more than one interval then it wont show the max value for those interval,Could you please explain me this how would I do this,I forgot to mention this in my Question