on 10-22-2013 10:45 PM
Hi All,
Can any one suggest how to do the percentage calculation(calculated attribute) on two aggregated columns in a graphical calc view?
Goutham
Create a new calculated column COLUMN_C with formula COLUMN_A / COLUMN_B * 100.0
Please share more details for a more detailed answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Below is the senario:
I need to show the number of customers with N/A as customer name, total number of customers and the percentage of customers with N/A as customer name from customer master table in the output of the calc view.
For modeling the above, I have created a graphical calc view with the customer table in projection and calculated columns TOTAL_CUSTOMERS and CUSTOMERS_NA_NAME as shown below and at the aggregation level, i have created calculated column PERCENTAGE_NA NAME as shown below:
CALCULATED COLUMN FORMULA
-------------------------------------- -----------------------------------
TOTAL_CUSTOMERS 1
CUSTOMERS_NA_NAME IF("CUSTOMER_NAME" = 'N/A ','1',0)
PERCENTAGE_NA NAME ("TOTAL_CUSTOMERS "/"CUSTOMERS_NA_NAME") * 100
Below are the results:
Actual result:
TOTAL_CUSTOMERS -- 46,464
CUSTOMERS_NA_NAME -- 547
PERCENTAGE_NA NAME -- 0
Expected result:
TOTAL_CUSTOMERS -- 46,464
CUSTOMERS_NA_NAME -- 547
PERCENTAGE_NA NAME -- 1.18
Goutham
Looks like you have the numerator and denominator mixed up here, assuming that was just a mistake in your write-up (but might want to check your model): PERCENTAGE_NA NAME ("TOTAL_CUSTOMERS "/"CUSTOMERS_NA_NAME") * 100
Assuming your model's calculated columns has the correct formula, make sure all respective data types are DECIMAL and not INTEGER. It is likely calculating division with 0s and thus truncating the result - therefore you get 0.
(I haven't test the ins and outs of implicit casting if one of the fields is decimal and the other integer - might work as well - but to be safe, stick with all DECIMAL types)
Please test on a very small sample set - i.e. 3 rows, in a very simple calculation view. If that works - then examine the differences between that calculation and the more complex, original model.
If it still doesn't work, copy the small dataset here as well as screenshots of the CalcView so that I can duplicate.
Thanks
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.