Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Nolgath
Creator
Creator

Average of Count() expression question.

COUNT({<vehicleStatus={0}>} vehicleStatus)

 

I have this expression and I just need to know that count's average. 

I've tried: 

AVG(COUNT({<vehicleStatus={0}>} vehicleStatus)) = wrong result.

avg(aggr(COUNT({<vehicleStatus={0}>} vehicleStatus),vehicleStatus)) -wrong result.

 

This is just for a KPI.

 

How can I do this?

 

 

Labels (6)
3 Replies
JordyWegman
Partner - Master
Partner - Master

Hi,

What are you trying to show here? Maybe you can give us some of you data, because right now your result will always be 1.

Say your data looks like this:

vehicleStatus
0
0
0
1
1


Assume your calculation:

COUNT({<vehicleStatus={0}>} vehicleStatus)

 

Result will be 3

2022-12-23 21_58_55-.png
But taking an average of this will always be one. Since count is equal to the number of rows.

Jordy

Climber

Work smarter, not harder
vinieme12
Champion III
Champion III

You need to specify which dimension you need to get the average by, if you aggregate on the same dimension as @JordyWegman  pointed out, the result will always be incorrect

If you want to take an average for all States/Cities for example, then specify as below

 

=Avg(aggr(COUNT({<vehicleStatus={0}>} vehicleStatus),STATE)) 

 

This is what the results of aggr look like

Capture.PNG

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

Hello,

 

So i have these fields:

dealer, country, vehicleStatus, currentPrice.

 

vehicleStatus contains : 0,1,2,3,4,5,6,7,8,9,10,11,12.  (0=Online) (1,2,3,4,5,6,7,8,9,10,11,12 = Sold)

dealer contains : names of dealers.

country contains : countries from europe.

currentPrice contains: Numeric value for price.

 

For the vehicleStatus, I did the formula :

COUNT({<vehicleStatus={0}>} vehicleStatus) for online cars and 

COUNT({<vehicleStatus-={0}>} vehicleStatus) for sold cars.

 

I have KPI for the average days online, average days to sell and average price when i choose some dealer. That is all good.

 

Now what I need is to compare this data with the market, like i choose dealer 1 and it shows me all about him then i also get the market average for average days online, average days to sell and average price.

 

That is why I need the average per country, I get huge numbers, maybe i need to do so that it calculates average days a car is only between all dealers of that country selected. I will upload a image of my dashboard in front end.