Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
frank1982
Contributor III
Contributor III

Arithmetical operations with table total column

Hi,

for this table:

Immagine4.png

I have to calculate the TOTAL average price (Column called 'Prezzo Medio') dividing the sum of field 'Imponibile' by the sum of field 'Quantità[kWh]-Perdite'.


In formula, the result of the column 'Prezzo Medio' has to be:

5.893,7/(110.640/1.000*)=53,27

Now, I only calculate the row divisions and aggregate them throw average, that is not the right way.

*1000 is a constant value for a conversion


Could you help me?

Thanks in advance.

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Try this

Sum(Aggr(

if((Sum(CONSUMO_TOTALE_KWH)/if(Year(DATA_INIZ_FORN)<2017 and (Year(DATA_FINE_FORN)>2017 or isnull(DATA_FINE_FORN)),12,

if(Year(DATA_INIZ_FORN)<2017 and Year(DATA_FINE_FORN)=2017,Month(DATA_FINE_FORN),

if(Year(DATA_FINE_FORN)>2017 or isnull(DATA_FINE_FORN),(12-Month(DATA_INIZ_FORN)+1),(Month(DATA_FINE_FORN)-Month(DATA_INIZ_FORN)+1)))))*12<=10000,

Sum(VENDITA_ENERGIA_MODULAZIONE)

,0)

,FORNITORE, POD))/

Sum(Aggr(

if((Sum(CONSUMO_TOTALE_KWH)/if(Year(DATA_INIZ_FORN)<2017 and (Year(DATA_FINE_FORN)>2017 or isnull(DATA_FINE_FORN)),12,

if(Year(DATA_INIZ_FORN)<2017 and Year(DATA_FINE_FORN)=2017,Month(DATA_FINE_FORN),

if(Year(DATA_FINE_FORN)>2017 or isnull(DATA_FINE_FORN),(12-Month(DATA_INIZ_FORN)+1),(Month(DATA_FINE_FORN)-Month(DATA_INIZ_FORN)+1)))))*12<=10000,

Sum(TOT_CONSUMO_PERDITE)

,0)

,FORNITORE, POD))*1000


Capture.PNG

View solution in original post

4 Replies
sunny_talwar
MVP
MVP

May be try like this

Sum(Aggr(Imponibile Expression Here, ChartDimension Here))/(Sum(Aggr(Quantità[kWh]-Perdite Expression Here, ChartDimension Here))/1000)

frank1982
Contributor III
Contributor III
Author

Thank you Sunny for the answer.

I tried the formula you suggest me, but it doesn't work.

Probably the problem is linked to the 'if' construct I have builted for the field 'Imponibile' and 'Quantità'.

To explain you better my project, I link you a small example (data and project).

Could you help me?

Thank you very much.

Franco

sunny_talwar
MVP
MVP

Try this

Sum(Aggr(

if((Sum(CONSUMO_TOTALE_KWH)/if(Year(DATA_INIZ_FORN)<2017 and (Year(DATA_FINE_FORN)>2017 or isnull(DATA_FINE_FORN)),12,

if(Year(DATA_INIZ_FORN)<2017 and Year(DATA_FINE_FORN)=2017,Month(DATA_FINE_FORN),

if(Year(DATA_FINE_FORN)>2017 or isnull(DATA_FINE_FORN),(12-Month(DATA_INIZ_FORN)+1),(Month(DATA_FINE_FORN)-Month(DATA_INIZ_FORN)+1)))))*12<=10000,

Sum(VENDITA_ENERGIA_MODULAZIONE)

,0)

,FORNITORE, POD))/

Sum(Aggr(

if((Sum(CONSUMO_TOTALE_KWH)/if(Year(DATA_INIZ_FORN)<2017 and (Year(DATA_FINE_FORN)>2017 or isnull(DATA_FINE_FORN)),12,

if(Year(DATA_INIZ_FORN)<2017 and Year(DATA_FINE_FORN)=2017,Month(DATA_FINE_FORN),

if(Year(DATA_FINE_FORN)>2017 or isnull(DATA_FINE_FORN),(12-Month(DATA_INIZ_FORN)+1),(Month(DATA_FINE_FORN)-Month(DATA_INIZ_FORN)+1)))))*12<=10000,

Sum(TOT_CONSUMO_PERDITE)

,0)

,FORNITORE, POD))*1000


Capture.PNG

frank1982
Contributor III
Contributor III
Author

It works!!!

Thank you very much!

Franco