Limit Rows Based On Upper And Lower Limits On Expressions

Announcements Write Table now available in Qlik Cloud Analytics: Read Blog
  • Qlik Community
  • All Forums
  • QlikView App Dev
  • Limit Rows based on Upper and Lower Limits on Expr...
Options All communityThis boardKnowledge baseUsersProducts cancel Turn on suggestions Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type. Showing results for  Search instead for  Did you mean:  Not applicable ‎2014-09-12 01:28 PM

Limit Rows based on Upper and Lower Limits on Expressions

Hi,

Is it possible to limit the rows based on limits on expressions? For example, I have sum(employees), sum(income), sum(tax) in my expressions and I want only those records to be displayed in my table where:

1. sum(employees) > 200 and sum(employees) < 500

2. sum(income) > $500 000 and sum(income) < $1000000

3. sum(tax) > $10 000

Is it possible to display only those records that fulfills upper and lower limits to above expressions ?

Thanks,

Sheetal

  • qlikview_scripting
Ditto - same here! 3,833 Views 0 Likes Reply
  • All forum topics
  • Previous Topic
  • Next Topic
  • Previous Replies
    • 1
    • 2
    • 3
  • Next Replies
21 Replies Not applicable ‎2014-09-14 10:04 PM Author In response to

Thanks Kalpesh for your reply. I want to show only those records where sum(Employees) > 200 and sum(Employees) < 500. So I will need to use calculated dimension. I tried the following but it shows me "1" in this column for all rows even though sum(Employees) is less than 200. I have tried only for first condition sum(Employees) > 200

=If( Aggr (sum(EMPLOYEES), EMPLOYEES)>200, EMPLOYEES)

Thanks,

1,472 Views 0 Likes Reply jagan Partner - Champion III jagan Partner - Champion III ‎2014-09-14 10:44 PM In response to

Hi,

Try like this

Expression:

If(sum(employees) > 200 and sum(employees) < 500 and sum(income) > 500000 and sum(income) < 1000000 and sum(tax) > 10000, 'True')

Note: You can replace True in the above expression with the value of your wish.

Hope this helps you.

Regards,

Jagan.

1,472 Views 0 Likes Reply Gysbert_Wassenaar Partner - Champion III Gysbert_Wassenaar Partner - Champion III ‎2014-09-15 03:58 AM In response to

The expression in the variable should NOT be starting with an = sign. Otherwise it will be evaluated outside the context of the chart.

talk is cheap, supply exceeds demand 1,473 Views 1 Like Reply Not applicable ‎2014-09-15 11:09 AM Author In response to Gysbert_Wassenaar

Thanks Gysbert !. However, I want to display only those rows fulfilling these conditions. I think calculated dimension can be used. I have tried below expression in calculated dimension, but it shows all rows with value 1 for all rows even those not fulfilling the condition.

=If( Aggr (sum(EMPLOYEES), EMPLOYEES)>200, EMPLOYEES)

1,473 Views 0 Likes Reply jagan Partner - Champion III jagan Partner - Champion III ‎2014-09-16 12:40 AM In response to

Hi,

Try like this

=Aggr (If(sum(EMPLOYEES) >200, EMPLOYEES))

Regards,

Jagan.

1,473 Views 0 Likes Reply Not applicable ‎2014-09-16 04:38 PM Author In response to

Hi Sheetal,

If haven't got this working yet, can you share few hundred rows of sample data in excel. Its much more easy to understand and provide the solution this way.

A note on this expression that you tried to use

If( Aggr (sum(EMPLOYEES), EMPLOYEES)>200, EMPLOYEES)

The Aggr function aggregates results of an expression (i.e. sum(EMPLOYEES)) against a dimension that comes after comma separator.

If you use Employees as the dimension, then the Aggr statement reads it as "Sum of Employees per Employees" which has to be one and that is what you are getting.

So it will help if you can share what are the other dimensions you are using in Chart. (not to forget the sample data in excel)

Regards,

Kalpesh

1,473 Views 0 Likes Reply Not applicable ‎2014-09-18 05:50 PM Author In response to

Thanks Kalpesh. I am using following sample data. I have created a straight table with following dimensions and expression.

Sample Data:

Load * Inline [

Period, ID, AccountType, Income

201401, 1, AAA, 100

201401, 1, BBB, 200

201401, 1, CCC, 300

201401,2, AAA, 200

201401,2, BBB, 100

201401,2, CCC, 400

201401,3, AAA, 300

201401,4, BBB, 400

201401,5, AAA, 100

201401,6, CCC, 200

201401,7, CCC, 100

201401,8, AAA, 500

201401,9, BBB, 100

201401,10,BBB, 900

];

Dimension:

1.AccountType

2.ID

3.=(If( Aggr (sum(Income), AccountType)>1200, Income)) with Suppress when value is Null checked

Expression:

1.Period

I am getting only 1 row in the output for AccountType BBB which is correct. But, I am getting Income displayed as 900. I want to show the sum(Income) instead of just Income. Hence, I want to display 1700 in a single row.

I also tried following:

1. =(If( Aggr (sum(Income), AccountType)>1200, Aggr (sum(Income), AccountType))) but this shows 5 rows each with 1700 value

2. =(If( Aggr (sum(Income), AccountType)>1200, Aggr (sum(Income), AccountType,ID))) but this shows 1 row with 200

Is this possible?

1,473 Views 0 Likes Reply jagan Partner - Champion III jagan Partner - Champion III ‎2014-09-18 09:11 PM In response to

Hi,

Try like this

Dimension: AccountType, ID

Expression: = Sum(Aggr(If(sum(Income)>1200, Sum(Income)), AccountType))

Hope this helps you.

Regards,

Jagan.

Ditto - same here! 3,144 Views 0 Likes Reply Anonymous Not applicable ‎2014-09-19 12:15 AM Author In response to jagan

HI,

ID DImension splits Income to 900. Skip ID DImension and then use the expression Jagan posted.

Best Regards

Stefan

1,473 Views 1 Like Reply Not applicable ‎2014-09-25 12:53 PM Author In response to jagan

Thanks Jagan. There is one change in the requirement. I have attached the sample file and output screenshot. I want to display only those rows that satisfies both the conditions (AND) instead of OR. i.e as per the expression applied, only one row satisfying both the condition should be displayed. Is this possible ?

Also, this is just a sample but in real scenario, I have about 10 such numeric columns that has lower and upper limits coming through variables whose values are entered by users

Data:

Sample_Data:

Load * Inline [

Company, ID, AccountType, No_Of_Emp, Revenue

A, 1, AAA, 28,300000

B, 1, BBB, 70,500000

C, 1, CCC, 80,450000

D,2, AAA, 200,2000000

E,2, BBB, 100,5000000

F,2, CCC, 70,750000

G,3, AAA, 300,6000000

H,4, BBB, 400,4500000

I,5, AAA, 100,2000000

J,6, CCC, 200,1500000

K,7, CCC, 250,2000000

L,8, AAA, 300,3000000

M,9, BBB, 100,400000

N,10,BBB, 105,900000

];

Dimension:

1. Company

2. ID

Expressions:

1. = Sum(Aggr(If(sum(No_Of_Emp)>200 AND SUM(No_Of_Emp) < 500, Sum(No_Of_Emp)), Company,ID))

2. = Sum(Aggr(If(sum(Revenue)>200000 and sum(Revenue) < 3000000, Sum(Revenue)), Company,ID))

Preview file 6 KB TEST.qvw 1,473 Views 0 Likes Reply Post Reply
  • Previous Replies
    • 1
    • 2
    • 3
  • Next Replies
Tags
  • new_to_qlikview
  • new to qlikview
  • qlikview_scripting
  • qlikview_layout_visuali…
  • qlikview_creating_analy…
  • qlikview
  • script
  • chart
  • expression
  • date
  • load
  • table
  • set_analysis
  • expressions
  • macro
  • analysis
  • scripting
  • pivot
  • set
  • dimension
View All ≫ Community Browser
  • All Forums
    • GeoAnalytics
    • QlikView Administration
    • QlikView App Dev
    • QlikView Connectivity
    • QlikView Integrations
    • Qlik NPrinting

Từ khóa » @j.k7ccc