Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rlawton1
Contributor III
Contributor III

Aggr Count Distinct function

I am struggling with getting total in Qliksense to match the totals if i export hte data to excel and sum the column.

The expression in the measure is:

       count(distinct(Pol_ID))*(Total_U_Ad/Total_U)

I understand the arrg function is what i need to use and it works perfectly on other columns with simpler expression but i cannot get it to work with this.

I have tried various methods including:

       count(aggr(only(distinct(Pol_ID)*(Total_U_Adq/Total_U)),Pol_ID))

       count(aggr(only(distinct(Pol_ID)),Pol_ID))*Sum(aggr( only(Total_U_Adq/Total_U),Total_U_Adq/Total_U)

       count(aggr(only(distinct(Pol_ID),TravellerId))*(Total_U_Adq/Total_U)

 

But nothing i do works, can somebody please help me?

Thanks in advance

Labels (4)
2 Replies
sunny_talwar

What dimensions do you use when you export the chart to the Excel? 

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

The reason for the difference between the total line and the sum of individual lines is the DISTINCT count - if some of the line results should be duplicated, they will get de-duplicated at the total.

If you want the total to be a sum of line values, you can simply modify the Totals Function to "Sum", and that will do the trick. 

If you want to solve the same problem using AGGR, then the syntax would be the following:

sum(

     AGGR(

                   count(distinct .....),

                   Dim1, Dim2, Dim3, ...

      )

)

where Dim1, Dim2, Dim3  are your chart dimensions.

 

Cheers,

Oleg Troyansky