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: 
Jqlik
Contributor
Contributor

Create a dynamic calculation

Hi everyone,

I need help with a calculation. I put an example:

I currently have this calculation created --> (Field 1 + Field 2 + Field 3 + Field 4)/4.

The problem is that sometimes some field is null. When this happens I want the division to change. For example:

(Field 1 + null + Field 3 + null)/2.

I want the calculation to only split the fields that are not null.

Thanks.

 

Labels (2)
2 Solutions

Accepted Solutions
Taoufiq_Zarra

@Jqlik  If I understood correctly ?

=RangeSum([Field 1],[Field 2],[Field 3],[Field 4])
/
RangeSum(if(len([Field 1])=0,0,1),if(len([Field 2])=0,0,1),if(len([Field 3])=0,0,1),if(len([Field 4])=0,0,1))

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

Kushal_Chawda

@Jqlik  as @marcus_sommer  suggested use rangecount instead like below

RangeSum([Field 1],[Field 2],[Field 3],[Field 4])/
Rangecount([Field 1],[Field 2],[Field 3],[Field 4])

View solution in original post

4 Replies
Taoufiq_Zarra

@Jqlik  If I understood correctly ?

=RangeSum([Field 1],[Field 2],[Field 3],[Field 4])
/
RangeSum(if(len([Field 1])=0,0,1),if(len([Field 2])=0,0,1),if(len([Field 3])=0,0,1),if(len([Field 4])=0,0,1))

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
marcus_sommer

Why not using rangecount() as divisor?

- Marcus

Jqlik
Contributor
Contributor
Author

Thanks! 

this solution is perfect.

 

Kushal_Chawda

@Jqlik  as @marcus_sommer  suggested use rangecount instead like below

RangeSum([Field 1],[Field 2],[Field 3],[Field 4])/
Rangecount([Field 1],[Field 2],[Field 3],[Field 4])