Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
dseelam
Creator II
Creator II

Weighted average

Hello Folks,

How to calculate weighted avg total for below statement for a straight table?


if(isnull(OldPrize),(sum(GROSS_SALES)/sum(SHIPPED_QUANTITY)),OldPrize)

8 Replies
sunny_talwar

I don't think we have enough information to provide any guidance... do you mind expanding and sharing a sample?

vishsaggi
Champion III
Champion III

What is the issue are your %ge not correct? Try this?

if(isnull(OldPrize), sum(GROSS_SALES)/sum(TOTAL SHIPPED_QUANTITY)),OldPrize)

dseelam
Creator II
Creator II
Author

Sunny,

I am trying to get Old price in a column and if its null trying to get new price which is sum(GROSS_SALES)/sum(SHIPPED_QUANTITY expression is working great but when it comes to total its calculating wrong -  would like to see the weighted average instead of normal avg of the column

dseelam
Creator II
Creator II
Author

Hey Vish,

if(isnull(OldPrize), sum(GROSS_SALES)/sum(TOTAL SHIPPED_QUANTITY)),OldPrize)


This part seems incorrect trying to get totals as weighted average instead of normal avg

sunny_talwar

What are your chart dimensions? This isn't what you want?

Avg(Aggr(if(isnull(OldPrize),(sum(GROSS_SALES)/sum(SHIPPED_QUANTITY)),OldPrize), YourChartDimensions))

What is the weight based on?

dseelam
Creator II
Creator II
Author

Hey Sunny,

My chart dimension is Item number but expression you sent me was giving normal avg of the column which is the same totals when I use default expression total

dseelam
Creator II
Creator II
Author

Sunny, attached an excel with an example column M is what am having using avg expression total, What I need was column 'O'

sunny_talwar

May be try this

Sum(Aggr(if(isnull(OldPrize),(Sum(GROSS_SALES)/Sum(SHIPPED_QUANTITY)),OldPrize), License, [Acct #], [Customer Name], Customer))/Sum(Quantity)