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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculate a grand total

Agg_Pha_Tmp:

  Load

  MEM#,              

  sum(PhaTotal) as SumPhaTotal

Resident pha               

group by MEM#;

Agg_Med_Tmp:               

Load

  MEM#,              

  sum(Total) as SumMedTotal

Resident med              

group by MEM#;

I am wondering how i can sum the SumPhaTotal and SumMedTotal (SumPhaTotal + SumMedTotal) to get a GrandTotal.

Thanks.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

I'd load them as one table instead of two from the very start.

Data:
LOAD MEM#, sum(PhaTotal) as SumPhaTotal
RESIDENT pha
GROUP BY MEM#
;
OUTER JOIN (Data)
LOAD MEM#, sum(Total) as SumMedTotal
RESIDENT med
GROUP BY MEM#
;
LEFT JOIN (Data)
LOAD MEM#, rangesum(SumPhaTotal,SumMedTotal) as GrandTotal
RESIDENT Data
;

View solution in original post

3 Replies
erichshiino
Partner - Master
Partner - Master

It could be like this:

Agg_Pha_Tmp:

  Load

  MEM#,              

  sum(PhaTotal) as SumPhaTotal

Resident pha               

group by MEM#;

Agg_Med_Tmp:               

Load

  MEM#,              

  sum(Total) as SumMedTotal

Resident med              

group by MEM#;

tAggr_Tmp:

Load MEM#, SumPhaTotal as SumTotal

resident Agg_Pha_Tmp;

concatenate (tAggr_Tmp)

Load MEM#, SumMedTotalas SumTotal

resident Agg_Pha_Med;

Aggr_Tmp:

Load MEM#, sum(SumTotal) as SumTotal

resident tAggr_Tmp

group by MEM#;

drop table tAggr_Tmp;

Hope this helps,

Erich

johnw
Champion III
Champion III

I'd load them as one table instead of two from the very start.

Data:
LOAD MEM#, sum(PhaTotal) as SumPhaTotal
RESIDENT pha
GROUP BY MEM#
;
OUTER JOIN (Data)
LOAD MEM#, sum(Total) as SumMedTotal
RESIDENT med
GROUP BY MEM#
;
LEFT JOIN (Data)
LOAD MEM#, rangesum(SumPhaTotal,SumMedTotal) as GrandTotal
RESIDENT Data
;

Anonymous
Not applicable
Author

John,

Thank you. It works.