Skip to main content
Announcements
Qlik Community Office Hours, March 20th. Former Talend Community users, ask your questions live. SIGN UP
cancel
Showing results for 
Search instead for 
Did you mean: 
jworthulf
Creator
Creator

sum does not equal total

I have two fields in a table and I have made selections in field one (text) values that have associated values in field 2.     When I go, to sum up the values of the fields that I've selected using sum(field) and my total is incorrect.  

Example

fields selected in a list box are B,C,D

Table 1

                    sum(Field2)

Field 1          Field 2

B                    5

C                    4    

D                    3

                                            

                      6 = Total

30 Replies
vishsaggi
Champion III
Champion III

Are there any duplicates or your expr is using any DISTINCT in your Sum() function in the front end worth a check.

rohanmayekar
Partner - Contributor III
Partner - Contributor III

Looks like, while calculating the sum only distinct data values were considered.

in given example Numbers 8 & 9 have multiple occurrences. While summing if only distinct values are considered then sum value will come up as 35 instead of 52.

balabhaskarqlik

There may be, a variable used in your measures expression, was not able to compute successfully. When you filter by that dimension as dimension did not affect the variable.

Try to amend the variable to ignore all filters, then the expression will be, able to compute even with filter applied.

sagarjagga
Creator
Creator

are you using distinct function for a dimension in set expression of sum? it could be possible that you might have some duplicates among dimensions. for total option, you can use SUM instead of auto

jworthulf
Creator
Creator
Author

Sager,

Thank you for the input are you suggesting the sum of rows in the total mode, when you say "you can use SUM instead of auto"?

Thanks,

John Worth

BI Data Analyst

Upper Lakes Foods

p: 800.879.1265 ext 4278

w: upperlakesfoods.com<http://upperlakesfoods.com/>

jworthulf
Creator
Creator
Author

Bala,

Can you show me an example?

Thanks,

John Worth

BI Data Analyst

Upper Lakes Foods

p: 800.879.1265 ext 4278

w: upperlakesfoods.com<http://upperlakesfoods.com/>

jworthulf
Creator
Creator
Author

Rohan,

Thank you for the feedback, the formula in the example was sum(Field 5), but I do see where using sum (distinct Field 5) would give you a result closer to 39.

Thank you,

John Worth

BI Data Analyst

Upper Lakes Foods

p: 800.879.1265 ext 4278

w: upperlakesfoods.com<http://upperlakesfoods.com/>

wdchristensen
Specialist
Specialist

sum(num(Field2))


jworthulf
Creator
Creator
Author

William,

Thanks for the update,

John Worth

BI Data Analyst

Upper Lakes Foods

p: 800.879.1265 ext 4278

w: upperlakesfoods.com<http://upperlakesfoods.com/>

wdchristensen
Specialist
Specialist

In your example the sum is less than the expected total.Is that actually happening or is the total to large? If you data model is incorrect I would expect the total to be duplicating values making to actual total larger. 


If you change sum to count, do you have to correct number of records?