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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
SarahAzizan
Partner - Contributor II
Partner - Contributor II

Incorrect total percentage in Table chart

Dear Experts,

 

I have a column Completion in table with some calculation. It is showing correct individual values but the total is wrong. 

Screenshot 2025-11-19 at 12.20.10 PM.png

Archival data #DOC = count( {$<SET={'Archival data'}>}distinct DOCNO)

Current data #DOC = count({$<SET={'Current data'}>}distinct DOCNO)

 

Completion = count({$<SET={'Current data'}>}distinct DOCNO) / count( {$<SET={'Archival data'}>}distinct DOCNO)

Completion column number formatting is Number 12.3%

 

The correct Total Completion % should be 62798 / 71722 = 0.8755 or 87.6%

 

Regards,

Sarah Azizan

Labels (6)
2 Solutions

Accepted Solutions
marcus_sommer

Only by using simple aggregations like sum(Field) or count(Field) are the totals a no brainer. As far as any conditions are applied and/or rates calculated and/or distinct is used and similar stuff the calculation depends on the context to the data-set + data-model + object-dimensionality - for example the conditions may be valid on the object row-level but not on the totals or there are overlapping DOCNO between the companies which will result in different numbers between the rows and the total - various possibilities ...

The general solution were already hinted and is to wrap the base-calculation with an appropriate aggr() construct. The dimensions for the aggr() are usually the object-dimensions but it may differ. Helpful is often to use a table-box with all relevant fields and investigate the existing relationship there (against an appropriate reduced data-set - means just a few rows but resulting in unexpected results).

View solution in original post

SarahAzizan
Partner - Contributor II
Partner - Contributor II
Author

Found the correct expression:

Completion = SUM(Aggr(count({$<SET={'Current data'}>}distinct DOCNO), [COMPANY_CODE] ))
/ SUM(Aggr(count( {$<SET={'Archival data'}>}distinct DOCNO), [COMPANY_CODE] )) 

Totals setting is Auto.

 

Thank you everyone for your guides & helps.

Regards,

Sarah Azizan

View solution in original post

9 Replies
Nagaraju_KCS
Specialist III
Specialist III

try this 

= count({<SET={'Current data'}>} distinct DOCNO)
/
count({<SET={'Archival data'}>} TOTAL distinct DOCNO)

Chanty4u
MVP
MVP

Try this 

Sum(

    Aggr( Count({$<SET={'Current data'}>} DISTINCT DOCNO), DOCNO )

)

Sum(

    Aggr( Count({$<SET={'Archival data'}>} DISTINCT DOCNO), DOCN

O )

)

Vegar
MVP
MVP

Are you sure that the row total of Archival data #DOC and Current data #DOC is correct? What is the setting for totalling in your table? Is it the expression total or is it sum of rows? The sum of rows totalling can be "wrong" in case you have dimensions in your table that share DOCNO with each other.

Try having your expression outside of this table, in a separate table with no dimensions. Is it correct then?

SarahAzizan
Partner - Contributor II
Partner - Contributor II
Author

The individual Completion value is not correct & Total Completion is the same 57.9% 

 

SarahAzizan
Partner - Contributor II
Partner - Contributor II
Author

The Completion value become all 0.00%

Nagaraju_KCS
Specialist III
Specialist III

try this

SUM(Aggr(count( {$<SET={'Archival data'}>}distinct DOCNO), [Company Code], [Company Name]))

/

SUM(Aggr(count({$<SET={'Current data'}>}distinct DOCNO), [Company Code], [Company Name]))

SarahAzizan
Partner - Contributor II
Partner - Contributor II
Author

The setting for totalling in the table is Auto.

Ya, looks like the value of the expression with no dimensions are different.

 

Screenshot 2025-11-19 at 2.38.04 PM.png

marcus_sommer

Only by using simple aggregations like sum(Field) or count(Field) are the totals a no brainer. As far as any conditions are applied and/or rates calculated and/or distinct is used and similar stuff the calculation depends on the context to the data-set + data-model + object-dimensionality - for example the conditions may be valid on the object row-level but not on the totals or there are overlapping DOCNO between the companies which will result in different numbers between the rows and the total - various possibilities ...

The general solution were already hinted and is to wrap the base-calculation with an appropriate aggr() construct. The dimensions for the aggr() are usually the object-dimensions but it may differ. Helpful is often to use a table-box with all relevant fields and investigate the existing relationship there (against an appropriate reduced data-set - means just a few rows but resulting in unexpected results).

SarahAzizan
Partner - Contributor II
Partner - Contributor II
Author

Found the correct expression:

Completion = SUM(Aggr(count({$<SET={'Current data'}>}distinct DOCNO), [COMPANY_CODE] ))
/ SUM(Aggr(count( {$<SET={'Archival data'}>}distinct DOCNO), [COMPANY_CODE] )) 

Totals setting is Auto.

 

Thank you everyone for your guides & helps.

Regards,

Sarah Azizan