Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

rlawton1
New Contributor

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

2 Replies

Re: Aggr Count Distinct function

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

MVP & Luminary
MVP & Luminary

Re: Aggr Count Distinct function

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