Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
mahnoor1279
Contributor III
Contributor III

Percentage of inputted fields by total number of fields.

I want to calculate the percentage of   (not null values of columns for each person / total no of columns)

Name email country cell no
sarah  sarah1278@gmail.com pakistan 342353463
adam     13254643
zain   india 1324322
Labels (4)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

as below

 

temp:
load Name,email,country,cellno
,  rangesum(if(len(Name),0,1),if(len(email),0,1),if(len(country),0,1),if(len(cellno),0,1)) as nullValues

inline [
Name,email,country,cellno
sarah,sarah1278@gmail.com,pakistan,342353463
adam,,,13254643
zain,,india,1324322
];

Main:
load *
,num((NoOfFields('temp')-2-nullValues) / (NoOfFields('temp')-2),'#,###.##%') as PercentageOfValues
Resident temp;
Drop table temp;

Exit script;

 

vinieme12_0-1671441510630.png

 

you can also avoid loading the Main table and calculate the same in front end using just the nullValues field as below

(3-sum(nullValues)) / 3

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

1 Reply
vinieme12
Champion III
Champion III

as below

 

temp:
load Name,email,country,cellno
,  rangesum(if(len(Name),0,1),if(len(email),0,1),if(len(country),0,1),if(len(cellno),0,1)) as nullValues

inline [
Name,email,country,cellno
sarah,sarah1278@gmail.com,pakistan,342353463
adam,,,13254643
zain,,india,1324322
];

Main:
load *
,num((NoOfFields('temp')-2-nullValues) / (NoOfFields('temp')-2),'#,###.##%') as PercentageOfValues
Resident temp;
Drop table temp;

Exit script;

 

vinieme12_0-1671441510630.png

 

you can also avoid loading the Main table and calculate the same in front end using just the nullValues field as below

(3-sum(nullValues)) / 3

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.