Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
stefan87
Contributor II
Contributor II

How does Avg() handle strings in script?

Hello Qlik Community,

I am using an Avg() function in my script, trying to calculate the average value of some numeric values (e.g. sales amounts).

However, some of my data contain text like 'N/A' which should not be taken into account when calculating the average value.

So my question is: Does Avg() ignore these values or does it sum them up as zero which will have an impact on the average?

Thank you very much in advance!

Stefan

4 Replies
sunny_talwar

AFAIK and based on testing =RangeAvg(1, 'NA', 2) = 1.5... Avg will ignore NA and find the average based on the numbers only.

keerthika
Creator II
Creator II

Hi,

    There is no impact, If the field (sales amounts) has 'N/A' value.It doesn't affect the sales amount avg

stefan87
Contributor II
Contributor II
Author

Thank you both for answering. This was what I expected, just wanted to check if I was right!

Stefan

naveenkumarchin
Partner - Contributor III
Partner - Contributor III

Hi Stefan,

unfortunately, it impacts avg but not sum.

When you have strings or nulls, and using aggregations, qlik will consider them as "Zero" while performing aggregation.

So for Sum, you may not see any effect. but for Avg() I think it will effect.

Thank you,

Naveen