Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
KC3
Creator
Creator

Sum for distinct

Dear Qlikians,

Having issue for getting Total for Distinct count.

I applied formula -Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code])

As need only done data in it please help me to get the sum/ total for this.

PFB image for this

 

KC3_0-1663308807478.png

 

Thanks in advance

 

Labels (2)
2 Solutions

Accepted Solutions
rubenmarin

Hi, you can try this one:

- Sum({<[Sale Order Status New]={'DONE'}>}Aggr(Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code]),Facility_Updated))

If the previous doesn't works:

- Sum({<[Sale Order Status New]={'DONE'}>}Aggr({<[Sale Order Status New]={'DONE'}>}Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code]),Facility_Updated))

Or use the first option: Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code]&'_'&Facility_Updated)

View solution in original post

KC3
Creator
Creator
Author

Thanks for the quick response it's really helpful Rubenmarin.

KC

View solution in original post

4 Replies
rubenmarin

Hi, the count is less than the sum of columns because there are [Display Order Code] in more than one Facility_Updated, so them counts in more than one column but just once in the totals.

To get the same sum you can use:

- Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code]&Facility_Updated)

- Sum(Aggr(Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code]),Facility_Updated))

But note that, if the same [Display Order Code] you get for different facilities is the same order, the total current  count you get is correct. If they are differnt and just have the coincidence to have the same number then you can use any of the above or create a composite key in script with [Display Order Code]&'_'&Facility_Updated and use the count distintc of this field.

KC3
Creator
Creator
Author

Hi Rube,

Thanks for that

Now the total is coming correct but in the table different status are coming how to remove it.

PFB image for you refrence.

KC3_0-1663311441287.png

 

 

rubenmarin

Hi, you can try this one:

- Sum({<[Sale Order Status New]={'DONE'}>}Aggr(Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code]),Facility_Updated))

If the previous doesn't works:

- Sum({<[Sale Order Status New]={'DONE'}>}Aggr({<[Sale Order Status New]={'DONE'}>}Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code]),Facility_Updated))

Or use the first option: Count(DISTINCT{<[Sale Order Status New]={'DONE'}>}[Display Order Code]&'_'&Facility_Updated)

KC3
Creator
Creator
Author

Thanks for the quick response it's really helpful Rubenmarin.

KC