Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
marcel_olmo
Partner Ambassador
Partner Ambassador

Count distinct Problem

Hi guys, I have a table of movements that describes a state of a code.

This code could be returned, and when is returned, it can be returned as "return", "qreturn" or "freturn".

I'm trying to count how many codes of each type of returned code I have in my document.

But I don't know why it counts in a weird way.

This is what I get :

MovMov DetailCounter
lendingfreturn1
qreturn203
return320
Total 411
Total 411

And this is my desired result (if I count properly) :

MovMov DetailCounter
lendingfreturn1
qreturn203
return320
Total 524
Total 524

Here I attach my test in Qlikview.

Do you know how is this happening? What I'm doing wrong?

Regards, Marcel.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

That's because your Code you count may relate to several Mov Detail values for the same Mov value.

Try

=sum(aggr( count(distinct {$< Returned ={'1'} >} Code ) , Mov, [Mov Detail]))

to do a sum-of-rows total in your pivot table.

View solution in original post

4 Replies
swuehl
MVP
MVP

That's because your Code you count may relate to several Mov Detail values for the same Mov value.

Try

=sum(aggr( count(distinct {$< Returned ={'1'} >} Code ) , Mov, [Mov Detail]))

to do a sum-of-rows total in your pivot table.

bbi_mba_76
Partner - Specialist
Partner - Specialist

Hi,

maybe I don't understand.

For example for code 9788401339080 you have both qreturn and return as [Mov Detail].

So this code is counted once in the total, and it is right.

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Thanks guys! With Aggr() I did my purpose!

Regards, Marcel.

israrkhan
Specialist II
Specialist II

Hi,

Find the attachment, its working...