Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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 - Specialist
Partner - Specialist

Post a sample app with expected output....

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

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

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
jonathandienst
Partner - Champion III
Partner - Champion III

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 - Specialist
Partner - Specialist

Hie...

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

Resident Data

Group By fieldname;

Regards,

Mohammad

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