Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
CasperQlik
Creator
Creator

AVG() returns NULL

Hi Qlik Community

I would like to calculate average scores across departments.

So a table that looks like this.

deptName avgScore
dept1 1.4
dept2 2.6
dept3 0.7
dept5 2.0

 

My table consists of a field [deptName] and a meassure avg(deptScore) but the meassure returns NULL across all departments.

Any advice is appretiaceted.


/Casper

1 Solution

Accepted Solutions
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

it looks like you are loading data as text. You may want to check:

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

7 Replies
SunilChauhan
Champion II
Champion II

num(deptScore) as NumDeptScore

AVG(NumDeptScore)

Sunil Chauhan
CasperQlik
Creator
Creator
Author

Edit: You are correct. It was a formatting issue with regards to English/Danish decimal point separator.

I replaced the decimal point and it now works.

 

Original reply: deptScore is already a number. 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

it looks like you are loading data as text. You may want to check:

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

@CasperQlik - can you show your field details in data model viewer? Is it loaded as numerical tag?

Lech_Miszkiewicz_0-1718186880616.png

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
CasperQlik
Creator
Creator
Author

You are correct. I discovered it just before reading your reply. The decimal delimiter was wrong and that formatted my value as a text. I tried with num() first but that did not work as you noted. I used the replace function and changed the delimiter and that automatically formatted my value to a number. The avg() function now return the expected result. 

CasperQlik
Creator
Creator
Author

Your intuition is correct as I replied to your previous post. The value is in fact loaded as text.

CasperQlik_0-1718187337852.png

 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

i suggest to study functions: num() only applies mask on the value which is already number (The function takes the numeric value of the input expression and generates a string representing the number.) so it has different purpose. num# function would be the one you could use, but using replace() can do the job too in this case.

https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Scripting/Formatt...

 

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.