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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic Grouping Based On Calculated Conditions

Hi Experts,

May I request for your assistance?


I created a pivot table in Qlik which resulted to the table below. However, I need to apply certain rules/computations which will help assign an agent to only 1 group and sub group. I have attached an XLS file which specifies the requirements and additional information needed  (such as date selection, rules, etc.).

Group

Sub-

Group

AgentsCountSalesTarget

A

1MULTI101,SINGLE101214603000
214506000
SUB-TOTAL319109000


B

3MULTI102, SINGLE10228206000
4MULTI102, SINGLE103211304000
SUB-TOTAL4195010000

Below is the expected result after rules are applied.

Group

Sub-

Group

AgentsCountSalesTarget

A

1SINGLE101114603000
2MULTI101,14506000
SUB-TOTAL219109000


B

3MULTI102, SINGLE10228206000
4SINGLE103111304000
SUB-TOTAL3195010000


If there are any clarifications regarding this item, please feel free to inform me.


Thank you in advance for your assistance.

2 Replies
settu_periasamy
Master III
Master III

Hi,

You can try something like in the script. But i'm not sure, how to link with you Date Filed. May be this script gives an idea to do in the Front End also.

T1:

LOAD * INLINE [

    COST CENTER, DATE, GROUP, SUBGROUP, AGENT, SALE, TARGET

    MAIN, 1-Jan-15, A, 1, MULTI101, 1300, 1000

    MAIN, 7-Jan-15, A, 2, MULTI101, 450, 6000

    MAIN, 12-Jan-15, A, 1, SINGLE101, 160, 2000

    MAIN, 15-Jan-15, B, 3, MULTI102, 470, 4000

    MAIN, 23-Jan-15, B, 4, MULTI102, 980, 3000

    MAIN, 24-Jan-15, B, 3, SINGLE102, 350, 2000

    MAIN, 31-Jan-15, B, 4, SINGLE103, 150, 1000

];

NoConcatenate

T2:

LOAD [COST CENTER], GROUP,

  SUBGROUP,

  CONCAT(AGENT,',') as AGENT,

  SUM(SALE) as SALE,

  SUM(TARGET) as TARGET

  Resident T1 Group by [COST CENTER], GROUP, SUBGROUP Order by SUBGROUP desc;

DROP Table T1;

NoConcatenate

T3:

LOAD [COST CENTER],GROUP,SUBGROUP,

  if(SubStringCount(AGENT,',')=0,AGENT,

  IF(SubField(AGENT,',',1)=Previous(SubField(AGENT,',',1)) and Previous(SubStringCount(AGENT,','))=0,

  SubField(AGENT,',',2),

  if( SubField(AGENT,',',1)=Previous(SubField(AGENT,',',1)) and TARGET>Previous(TARGET),

  AGENT,SubField(AGENT,',',2)))) as AGENT,

  SALE,

  TARGET

  Resident T2 Order by SUBGROUP desc;

DROP Table T2;

Capture.JPG

Or, You can even try with calculated dimension like

=Aggr(Concat(DISTINCT AGENT,','),GROUP,SUBGROUP)  // Tried this, but not get your expected result.

Not applicable
Author

Hi settu_periasamy,

The script is really useful. Thank you very much. However, it is a requirement that we consider the date selection. I am also trying to find a way to utilize what you have provided.

Still hoping to find an alternative to solve this matter considering the date selection.

Thank you for the new learning,

Wilfred