Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
arusanah
Creator II
Creator II

Pivot Help

    Data Set

Person IDMONTHYEARPlan GRPNew EnrollmentEnrollmentDisenrollment
11111January2016AYYN
11111February2016ANYN
11111March2016CNYN
11111April2016CNYN
11111May2016CNYY
11112May2016AYYN
11112June2016ANYN
11112July2016ANYY
11113June2016BYYN
11113July2016BNYN
11114January2016CYYN
11114February2016CNYN
11114March2016DNYN
11114April2016CNYN
11114May2016CNYY
11115January2016DYYN
11115February2016DNYN
11115March2016DNYN
11115April2016BNYN
11115May2016BNYN
11115June2016CNYN
11115July2016DNYN
11116January2016DYYN
11116February2016DNYN
11116March2016DNYN
11116April2016DNYY
11117January2016AYYN
11117February2016ANYN
11117March2016ANYN
11117April2016CNYN
11117May2016CNYY

   

Desired Out Put
Most Recent Grp
ABCD
Previous GrpA1111
B1111
C1111
D1111

               

My Requirement is to Generate a Pivot report in the above mentioned Format. This report is usually generated  Monthly. So when report is generated Person is counted in previous grp as well as new grp. For example in month  of JAN person 11111 was in plan A . He was in same plan in month Feb . but in March he moved from Plan A to plan C . so in above mentioned report he will be counted in plan A as well as plan C.   !!!





I'm facing difficulty how can I add current month value & Pervious month value in same cell

I am using following expression in QVW  at this point . how can I modify it to get above output.

Count({$<[Plan GRP]={'A','B','C','D'}>} distinct(([Person ID])))  ----- Current month Expression


Count({$<[Plan GRP]={'A','B','C','D'}, Month=(=month(addmonths(max(MonthYear)-1))>} distinct(([Person ID])))  ----- Last month Expression




Pls Help

7 Replies
arusanah
Creator II
Creator II
Author

my guess is it shud be sum of current month count  & Previous month count .

so  far not able to merge above expressions.

sunny_talwar

Is this what you want?

Capture.PNG

Script Changes:

Test1:

LOAD [Person ID],

  MONTH,

  YEAR,

  Date(MonthStart(Date#(MONTH & '-' & YEAR, 'MMM-YYYY')), 'MMM-YYYY') as MonthYear,

  [Plan GRP],

  [New Enrollment],

  Enrollment,

  Disenrollment

FROM

[Test1.xlsx]

(ooxml, embedded labels, table is Sheet3);

FinalTest:

LOAD *,

  If([Person ID] = Previous([Person ID]), Previous([Plan GRP])) as [prev Plan Grp]

Resident Test1

Order By [Person ID], MonthYear;

DROP Table Test1;

sunny_talwar

Or may be this:

Capture.PNG

Expression difference:

1st response: Count({$<[Plan GRP]={'A','B','C','D'}>}[Person ID])

2nd response (this post): Count(DISTINCT{$<[Plan GRP]={'A','B','C','D'}>}[Person ID])

arusanah
Creator II
Creator II
Author

Hey Sunny ,

its not letting me open ur QVW file . is it possible to for u to send  me script.

sunny_talwar

I did put the script with my 1st response. Did you miss the 1st response by any chance?


arusanah
Creator II
Creator II
Author

Thank You Sunny . I knew you would be able to help me

Thank you so very Much !!!

sunny_talwar

.... I was not too confident as to what you needed... But I am glad I was able to help.


Best,

Sunny