Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
emilyrabbit
Creator
Creator

count with conditional group by

Hi buddy, I have below request, no idea how to create the expression. Thanks for any suggestion.

I have a table: [Year Month],[Sales Admin],[Order]

emilyrabbit_0-1761269805517.png

I want to calculate the active user ( the user should have >1 order) number in each month.The example excel is attached.

The final chart what I want.

emilyrabbit_1-1761270174550.png

 

I want to write the expression in the chart , not in the loading script.

=count({<aggr((count(distinct[Order]),[Year Month],[Sales Admin])>1)>}distinct[Sales Admin])

@hanna_choi 

Labels (2)
4 Replies
hanna_choi
Partner - Creator II
Partner - Creator II

Hello @emilyrabbit 

Expression : 
Count( DISTINCT Aggr( IF(Count({<[Year Month]>} Order) > 1, [Sales Admin]), [Year Month], [Sales Admin] ) )

hanna_choi_0-1761280022589.png

Notice :

The use of if syntax within a set analysis can cause performance issue.

If you have a lot of data, the solution is group by in data modeling.

 

Amit_Prajapati
Creator II
Creator II

@emilyrabbit ,

You can create a flag in the script by counting Orders grouped by YearMonth and Sales Admin. Then use that flag in your set expression like this:

count({<Flag={'Yes'}>} Order)

This makes your expression faster and more efficient.

anat
Master
Master

load YM,Sales,Order from table;

load YM,Sales,count(Order) as Nooforders resident group by YM,Sales;

 

then in frontend use Nooforders >1

emilyrabbit
Creator
Creator
Author

emilyrabbit_0-1761299219548.png

 

TEMP3:
NoConcatenate
Load
[Order Created By Rep]&Year([Order Header Creation Date]) &Num(Month([Order Header Creation Date]),00) as key,
Count(DISTINCT ([Order Document Number])) as COUNTNUM
from *** (qvd)
where _KEY_Unit_DWHK='2'
Group BY [Order Created By Rep],(Year([Order Header Creation Date]) &Num(Month([Order Header Creation Date]),00));

HI , I tried in the loading script. and [Order Header Creation Date] is a date format, I need to transform it to YYYYMM , the loading is failed .It shows invalid expression. Could you pls help me checking it ?Thanks.