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

How to exclude max and min value in qlikview

Hi

II have scenario,

I have data set like below

Year Location Sales

2016   Delhi    28

2016   Delhi     34

2016   delhi       45

2016    delhi      56

2016    delhi        23

2016    delhi       10

from the above data set i want to exclude max and min value

result

Year Location Sales

2016   Delhi    28

2016   Delhi     34

2016   delhi       45

2016    delhi        23

Is there any functions available to achieve this.

Thanks

Thiru

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi Thiru,

Do you want to remove it on script or on expression?

In script:

Table:

LOAD * INLINE [

    Year, Location, Sales

    2016, Delhi, 28

    2016, Delhi, 34

    2016, Delhi, 45

    2016, Delhi, 56

    2016, Delhi, 23

    2016, Delhi, 10

];

LEFT JOIN (Table)

LOAD

    Year,

    Location,

    Min(Sales)    as Sales,

    1            as MinValue

RESIDENT Table

GROUP BY Year, Location;

LEFT JOIN (Table)

LOAD

    Year,

    Location,

    Max(Sales)    as Sales,

    1            as MaxValue

RESIDENT Table

GROUP BY Year, Location;

NoConcatenate

FinalTable:

LOAD

    Year,

    Location,

    Sales

RESIDENT Table

WHERE MaxValue <> 1 and MinValue <> 1;

On expression:

Sum(Aggr(Sum({<Sales=P({<Sales={">$(=Min(Sales))<$(=Max(Sales))"}>}Sales)>}Sales),Year,Location,Sales))

Regards!

View solution in original post

11 Replies
bindu_apte
Creator III
Creator III

Hi,

Hope this will help you.

(sum(Sales) - max(Sales) - min(Sales) )

Not applicable
Author

Hi Bindhu,

I didn't get you?

van you please explain?

Thiru

tresesco
MVP
MVP

In the script or UI chart?

Not applicable
Author

In the script

Anonymous
Not applicable
Author

Hi Thiru,

Do you want to remove it on script or on expression?

In script:

Table:

LOAD * INLINE [

    Year, Location, Sales

    2016, Delhi, 28

    2016, Delhi, 34

    2016, Delhi, 45

    2016, Delhi, 56

    2016, Delhi, 23

    2016, Delhi, 10

];

LEFT JOIN (Table)

LOAD

    Year,

    Location,

    Min(Sales)    as Sales,

    1            as MinValue

RESIDENT Table

GROUP BY Year, Location;

LEFT JOIN (Table)

LOAD

    Year,

    Location,

    Max(Sales)    as Sales,

    1            as MaxValue

RESIDENT Table

GROUP BY Year, Location;

NoConcatenate

FinalTable:

LOAD

    Year,

    Location,

    Sales

RESIDENT Table

WHERE MaxValue <> 1 and MinValue <> 1;

On expression:

Sum(Aggr(Sum({<Sales=P({<Sales={">$(=Min(Sales))<$(=Max(Sales))"}>}Sales)>}Sales),Year,Location,Sales))

Regards!

teiswamsler
Partner - Creator III
Partner - Creator III

Hi Thiru

Try this

1. Load Data

     DataTmp:

     Load

          Year,

          Location,

          Sales

     From Data;

2. Identify the Min and Max value from DataTmp

  

     MinMax:

     Load

          Max( Sales ) as MaxSales,

          Min( Sales ) as MinSales

     Resident DataTmp;

   

     Let vMin = Num(Peek('MinSales', 0, 'MinMax'));

     Let vMax = Num(Peek('MaxSales', 0, 'MinMax'));

     DROP Table MinMax;

3. Reduce Data

  

     Noconcatenate

     MasterData:

     Load

     *

     Resident DataTmp

          Where

               Sales > $(vMin)

               and

               Sales < $(vMax)

     ;

     DROP Table DataTmp;

Hope it will help you

/Teis

qlikviewwizard
Master II
Master II

DataTemp:

Load * Inline [

Year, Location, Sales

2016,Delhi,28

2016,Delhi,34

2016,delhi, 45

2016,delhi,56

2016,delhi,  23

2016,delhi, 10

];

MinMax:

Load

Max( Sales ) as MaxSales,

Min( Sales ) as MinSales

Resident DataTemp;

 

Let vMin = Num(Peek('MinSales', 0, 'MinMax'));

Let vMax = Num(Peek('MaxSales', 0, 'MinMax'));

DROP Table MinMax;

NoConcatenate

MasterData:

Load

*

Resident DataTemp

Where

Sales > $(vMin)

and

Sales < $(vMax);

DROP Table DataTemp;

Capture.PNG

tresesco
MVP
MVP

PFA

AA:

Load * Inline [

Year, Location, Sales

2016,   Delhi,   28

2016,   Delhi,    34

2016,   delhi,      45

2016,    delhi,      56

2016,    delhi,        23

2016,    delhi,       10];

Temp:

Load max(Sales) as Max,

  Min(Sales) as Min Resident AA;

Let vMax=Peek('Max');

Let vMin=Peek('Min');

NoConcatenate

Final:

Load

  *

Resident AA where not Match(Sales, $(vMax),$(vMin));

Drop Tables Temp, AA;

effinty2112
Master
Master

Hi Thiru,

                    I added a row no to your data:

Data:

Load

*,

RowNo();

LOAD * INLINE [

    Year, Location, Sales

    2016,   Delhi,    28

    2016,   Delhi,     34

    2016,   delhi,       45

    2016,    delhi,      56

    2016,    delhi,        23

    2016,    delhi,       10

];

This table gives you what you want I hope:

RowNo() Location Year Sum(if(Sales > min(TOTAL Sales) and Sales < max (TOTAL Sales), Sales ))
130
1Delhi201628
2Delhi201634
3delhi201645
5delhi201623

Regards

Andrew