Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to get distinct count of No. of orders

Hi,

I wolud like to know the count of unique orders when below conditions get satisfied:

DateKey>=SelectDateFrom and DateKey<=SelectDateTO

My expression is:

COUNT(IF(DateKey>=SelectDateFrom and DateKey<=SelectDateTo,(DISTINCT([Order Count]))))

i do not know, where I am doing wrong.

any idea?

Thanks in advance.


1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this expression

=COUNT({<DateKey={'>=$(=SelectDateFrom)<=$(=SelectDateTo)'>} DISTINCT [Order Count])

Or you can also try like this.  In you Order table arrive a new column (OrderCount) with value 1 for every record and use the following expression

=Sum({<DateKey={'>=$(=SelectDateFrom)<=$(=SelectDateTo)'>} OrderCount)

Because Distinct may cause performance issues.

Hope this helps you.

Regards,

Jagan.

View solution in original post

7 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this expression

=COUNT({<DateKey={'>=$(=SelectDateFrom)<=$(=SelectDateTo)'>} DISTINCT [Order Count])

Or you can also try like this.  In you Order table arrive a new column (OrderCount) with value 1 for every record and use the following expression

=Sum({<DateKey={'>=$(=SelectDateFrom)<=$(=SelectDateTo)'>} OrderCount)

Because Distinct may cause performance issues.

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi Jagan,

thanks for ur quick reply.

i have to use ur first solution as order count is a test column.

below expression is showing red line when pasted it in Edit Expression.u know what is wrong?

=COUNT({<DateKey={'>=$(=SelectDateFrom)<=$(=SelectDateTo)'>} DISTINCT [Order Count])

Not applicable
Author

Hi jagan,

=COUNT({<DateKey={'>=$(=SelectDateFrom)<=$(=SelectDateTo)'>} DISTINCT [Order Count])

Can i know why you are keeping = sign in blue colored area in your expression ? Actually i'm not much aware of this concept.

Thanks in advance.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Is SelectDateFrom and SelectDateTo are variables? If they are not variables then post some sample data, so that it would be easier to understand.

Regards,

Jagan.

sivarajs
Specialist II
Specialist II

You missed curly brace before distinct

COUNT({<DateKey={'>=$(=SelectDateFrom)<=$(=SelectDateTo)'}> }DISTINCT [Order Count])

Not applicable
Author

Sivaraj change did the trick.

Thank you Jagan & Sivaraj.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Please close this discussion if your problem solves.

Venkat :

For Date fields we need to put =.

Regards,

jagan.