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

Calculating average on a measure instead of a column

I have a table with multiple columns. Using few of the columns I have to calculate another column named 'Final Data'. I am doing this by a measure instead of adding a calculated column in the table. Further, I need to create a measure that calculates AVERAGEIF equivalent on 'Final Data' by applying various conditions and then plot on a chart.

As it turns out, the following expression gives me an error

Avg(If([Asset] = 'A', [Final Data])) where 'Asset' is the name of an actual column in my master table and ‘Final Data’ is the measure I used to create the column I needed.

This seems to only work for actual columns and not measures.

Please suggest what can be done.

Labels (2)
10 Replies
AlBoo8749
Contributor II
Contributor II

Does If([Asset] = 'A', Avg([Final Data]),0) work for you?

saurabh_Qlik1
Contributor III
Contributor III
Author

No, it still returns an error. 

Chanty4u
MVP
MVP

Try this 

Avg(Aggr(Sum({<Asset={'A'}>} [Final Data]), Dimension1, Dimension2))

AlBoo8749
Contributor II
Contributor II

What is an example of the entries for 'Dimension1' and 'Dimension2'? I am asking because I have a similar problem. Are they other fields?

Chanty4u
MVP
MVP

Yes your dimensions fields it will aggregate your data based on that fields 

AlBoo8749
Contributor II
Contributor II

Thank you!

Chanty4u
MVP
MVP

Is that solution working?

 

Kushal_Chawda

@saurabh_Qlik1  what is the expression of Final Data?

saurabh_Qlik1
Contributor III
Contributor III
Author

Hi, thanks for your response. 

The expression for 'Final Data' is a simple one:

=[Spread] / (([Change 1] + [Change 2] + [Change 3] + [Change 4])/4

where all these are columns in my dataset.