Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

aggr sum need result to be sum of rows type total

Hi All

I'm trying to add a weighting to a count based on dividing 2 percentages and then multiplying them by the old count across certain dimensions.  If I put this in a straight table with dim1, dim2 and dim3 then create a normal expression total I get the result the aggr is giving but what I want is what I get when I change the expression total to sum of rows - can anyone advise how I can get this kind of result from an aggr expression?  Here's the expression I have that is giving the normal expression total as a result:

=sum(

aggr(

(((count({<FlagA={1}>}  ACCOUNT_ID)

/count({<FlagA={1}>} TOTAL ACCOUNT_ID))

/

(count({<FlagB={1}>}  ACCOUNT_ID)

/count({<FlagB={1}>} TOTAL ACCOUNT_ID)))

*count({<FlagB={1}>}  ACCOUNT_ID)),

dim1, dim2, dim3))

Please can someone advise?

Thanks

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

=SUM(Aggr((((count({<flagA={1}>}  account_ID)

/count({<flagA={1}>} TOTAL account_ID))

/

(count({<FlagB={1}>}  account_ID)

/count({<FlagB={1}>} TOTAL account_ID)))),dim1,dim2,dim3)

*Aggr(Count(account_ID),dim1,dim2,dim3))

View solution in original post

6 Replies
MK_QSL
MVP
MVP

=Avg(

aggr(

(((count({<FlagA={1}>}  ACCOUNT_ID)

/count({<FlagA={1}>} TOTAL ACCOUNT_ID))

/

(count({<FlagB={1}>}  ACCOUNT_ID)

/count({<FlagB={1}>} TOTAL ACCOUNT_ID)))

*count({<FlagB={1}>}  ACCOUNT_ID)),

dim1, dim2, dim3))

Not applicable
Author

Can you give sample QVW with data?

MK_QSL
MVP
MVP

Or may be

=sum(TOTAL

aggr(

(((count({<FlagA={1}>}  ACCOUNT_ID)

/count({<FlagA={1}>} TOTAL ACCOUNT_ID))

/

(count({<FlagB={1}>}  ACCOUNT_ID)

/count({<FlagB={1}>} TOTAL ACCOUNT_ID)))

*count({<FlagB={1}>}  ACCOUNT_ID)),

dim1, dim2, dim3))

Not applicable
Author

the first parameter of the aggr function should also be a function. this probabluy work

=sum(

aggr(

sum(

  (

    (

       count({<FlagA={1}>}  ACCOUNT_ID) /count({<FlagA={1}>} TOTAL ACCOUNT_ID)

     )

     /

     (

        count({<FlagB={1}>}  ACCOUNT_ID)/count({<FlagB={1}>} TOTAL ACCOUNT_ID)

      )

   )

   *

   count({<FlagB={1}>}  ACCOUNT_ID)

),

dim1, dim2, dim3))

Not applicable
Author

Hi

thanks for replying, unfortunately your suggestions didn't work the way I was looking for.

If you look at the attached I'm looking to get the 73.8466 result but using a single expression, i.e. without the need for a chart.

Thanks for helping

MK_QSL
MVP
MVP

=SUM(Aggr((((count({<flagA={1}>}  account_ID)

/count({<flagA={1}>} TOTAL account_ID))

/

(count({<FlagB={1}>}  account_ID)

/count({<FlagB={1}>} TOTAL account_ID)))),dim1,dim2,dim3)

*Aggr(Count(account_ID),dim1,dim2,dim3))