Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
harindersingh
Contributor III
Contributor III

Division of Count in Script

Hi,

I hope you all are doing well. I want to ask one question.

I have two fields in my table having String and Numeric Values

Fields a having 1000 Records & fields B having 700 I want to divide these two Fields and Want to create New Fields as Percentage in Script Itself not in chart.

Data is as below

    A                                                       B

35087982308                                35087982308

44058947209                                44058947209

1B007394207                               1B007394207

1H001557008                               1H001557008

1M006698108                               1M006698108

Total=1000                                   Total=700

Total (B)/Total (A) =%  

Any Suggestion Please Help  

Thanks

7 Replies
mohammadkhatimi
Partner
Partner

Post a sample app with expected output....

kaushiknsolanki
Luminary Alumni
Luminary Alumni

Hi,

Try this.

A:

Load FieldA From XYZ;

Let vTableA = NoOfRows('A');

B:

Load FieldB From XYZ;

Let vTableB = NoOfRows('B');

Load $(vTableA)/$(vTableB) as Percentage

Autogenerate 1;

Drop table A,B;

Regards,

Kaushik Solanki

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
jonathandienst

Do you mean to count them? in script?

LOAD Count(A) As CountA / Count(B) As Percentage

Resident Data;

Let vPercentage = Num(Peek('Percentage'), '0.0%');

Use Field Percentage or variable vPencentage.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
sunilkumarqv
Specialist II
Specialist II

try this in script @

Load Count(A)/Count(B) as percantage resident tablename;

mohammadkhatimi
Partner
Partner

Hie...

Load Count(A) / Count(B) As Percentage

Resident Data

Group By fieldname;

Regards,

Mohammad

harindersingh
Contributor III
Contributor III
Author

Thank you so much Kaushik for you help

This is what i am looking for

MarcoWedel

Hi,

one solution to add a new field in the same table could be:

QlikCommunity_Thread_177983_Pic1.JPG

//test data generation

table1:

LOAD If(Rand()>0.1,Left(KeepChar(Hash256(RecNo()),'01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'),11)) as A,

    If(Rand()>0.3,Left(KeepChar(Hash256(RecNo()),'01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'),11)) as B

AutoGenerate 1100;

//Percentage field

Left Join (table1)

LOAD Num(Count(B)/Count(A),'0%') as Percentage

Resident table1;

hope this helps

regards

Marco