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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

QlikView Aggregation Calculation, need help

Hi Everyone,

I ran into a problem when trying to calculate one of the charts %

So chart is displaying percentages at item level while i also have item group(therapeutic class)  witch is higher aggregation .

Currently it displayed top 5 items  for each therapeutic class .

The problem is that i need to take total amount in that therapeutic class not just for 5 items that are displayed but for all item and display percentage for those 5 items from total for the class . Please see below screenshot of the chart and my attempt to calculate that. Currently it only calculates percentage for one item in each class, but i need to display it for each item.

The code works if i do not do aggr in second part but it doesn't give me desired results . The reason i do aggr in second part is to get total for the whole class not just for those 5 items .

So pretty much its item /total (of the whole class )

Num(

(Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} [MI EXT$]) +

Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} [Returns Net_Amount]) +

Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} CNet_Amount))

/

Aggr(Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>}[MI EXT$]) +

Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>} [Returns Net_Amount]) +

Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>} CNet_Amount),THPY_GRP_CD),$(vFmt%))

On the screenshot you can see that its only calculates percentage for one random item but i need for each item .

In first one you can see its 40% which is correct number .

Its last column's total divided by net purchases .

2016-03-18 09_03_45-100-BIQVW-D-002.ABSG.NET - Remote Desktop Connection.png

Thank you in advance!!!!!!!!!!!!!!!!!

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Num(

(Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} [MI EXT$]) +

Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} [Returns Net_Amount]) +

Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} CNet_Amount))

/

Aggr(NODISTINCT Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>}[MI EXT$]) +

Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>} [Returns Net_Amount]) +

Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>} CNet_Amount),THPY_GRP_CD),$(vFmt%))

View solution in original post

4 Replies
amayuresh
Creator III
Creator III

Please share sample data.


sunny_talwar

Try this:

Num(

(Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} [MI EXT$]) +

Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} [Returns Net_Amount]) +

Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} CNet_Amount))

/

Aggr(NODISTINCT Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>}[MI EXT$]) +

Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>} [Returns Net_Amount]) +

Sum({$<YearMonthNumber={"$(vCurrPeriodRange)"}>} CNet_Amount),THPY_GRP_CD),$(vFmt%))

Kushal_Chawda

I am not sure but give it a try

Num(

(Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} [MI EXT$]) +

Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} [Returns Net_Amount]) +

Sum({($<[CNT_ID]={Y}> + $<[Returns Contract_Indicator]={Y}> + $<Contract_Indicator={Y}>) * $<YearMonthNumber={"$(vCurrPeriodRange)"}>} CNet_Amount))

/

Sum(total <Item> {$<YearMonthNumber={"$(vCurrPeriodRange)"}>}[MI EXT$]) +

Sum(total <Item> {$<YearMonthNumber={"$(vCurrPeriodRange)"}>} [Returns Net_Amount]) +

Sum(total <Item> {$<YearMonthNumber={"$(vCurrPeriodRange)"}>} CNet_Amount),THPY_GRP_CD))

Not applicable
Author

Thank you that worked !!!