Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
maxsheva
Creator II
Creator II

Replace Count with Sum. Do or not and how.

Hi,

I already read this article A Myth About Count(distinct …)

As far as I understand we may use count distinct in script.

But can we use count distinct in expressions?


Should I first make count in script and then do sum in expression?

What is the best method of that?


Thanks.

3 Replies
sunny_talwar

You can do Count(DISTINCT Measure) in an expression... why do you want to do this in the script?

maxsheva
Creator II
Creator II
Author

Hi Sunny,

Thanks for reply.

For example you may find info from the attached doc where says

"Count ( Distinct 'Field Name') Replace the count() with sum() and the distinct qualifier by assigning the value '1' to each distinct occurrence as it is read in the script"

I saw such examples on other sources too.

Should I do in script
1 as flag

and then calculate Sum(flag) in expressions?

tresesco
MVP
MVP

May be one more read of the blog A Myth About Count(distinct …) would help you understand it better. The attached pdf documentation is outdated. You might not have to use a flag and you can directly use Count(Distinct ..) in expression.