Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

21 Replies
Not applicable
Author

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,

jagan
Luminary Alumni
Luminary Alumni

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.

Gysbert_Wassenaar

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

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)

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this


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


Regards,

Jagan.

Not applicable
Author

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

Not applicable
Author

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?

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Dimension: AccountType, ID

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

Hope this helps you.

Regards,

Jagan.

Anonymous
Not applicable
Author

HI,

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

Best Regards

Stefan

Not applicable
Author

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))