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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
johnnyjohn
Creator
Creator

Ignore empty value in weighted average calculation

Hi, 

I have the below formula that calculates a weighted average. 

Sum(Total n5_fi_sprdcap_tt_touch * Aggr(Sum(n5_fi_value_EUR), n5_fi_sprdcap_tt_touch)) / Sum(Total Aggr(Sum(n5_fi_value_EUR), n5_fi_sprdcap_tt_touch))

How can I adapt this so that it only calculates the weighted average where n5_fi_sprdcap_tt_touch is not null? At the moment it will calculate including it. 

Thanks

1 Reply
chris_djih
Creator III
Creator III

my first thought is: build a flag for this condition in the script and put it in a set-analysis.

Load *,
   if (len(trim(n5_fi_sprdcap_tt_touch))=0,1,0) as isNull
resident table;

And then you can exclude it in the Set-Analysis: {<isNull={0}>}.

If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.