Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

use "where" on pivot table

Hello,

I have a data of payments made by subscribers:

P_SUBSC_NO,        INST_# ,    AMOUNT,   ANNOTATION,     STATUS

200000000 ,                      8 ,              15 ,                122-235 ,               old

200000000 ,                      9 ,              15 ,                122-235 ,               old

200000000 ,                      10,              15 ,                122-235 ,              old

200000000 ,                      11,              15 ,                122-235 ,              old

200000000 ,                      12,              15 ,                122-235 ,              old

200000000 ,                      13,              15 ,                122-235 ,              old

200000000 ,                      14,              15 ,                122-235 ,              current

200000000 ,                      4 ,               69 ,                 764-183,              old

200000000 ,                      5 ,               69 ,                 764-183,              old

200000000 ,                      6,               69 ,                 764-183,               old

200000000 ,                      7,               69 ,                 764-183,               old

200000000 ,                      8,               69 ,                 764-183,               old

200000000 ,                      9,               69 ,                 764-183,               pending


I want to show on the pivot table the most recent status (the one where the inst_# is the highest)

So, basically it should show on 122-235 the status current and on 764-183 pending

P_SUBSC_NOANNOTATIONSTATUSINST_#4567891011121314
200000000122-235// Error in calculated dimension15151515151515
764-183// Error in calculated dimension69696969696969

Thank you

1 Solution

Accepted Solutions
PrashantSangle

Hi,

I have done it in script.

Test:

LOAD * INLINE [

P_SUBSC_NO,INST_#,AMOUNT,ANNOTATION,STATUS

200000000 ,8 ,15 ,122-235,old

200000000 ,9 ,15 ,122-235,old

200000000 ,10,15 ,122-235,old

200000000 ,11,15 ,122-235,old

200000000 ,12,15 ,122-235,old

200000000 ,13,15 ,122-235,old

200000000 ,14,15 ,122-235,current

200000000 ,4,69 ,764-183,old

200000000 ,5,69 ,764-183,old

200000000 ,6,69 ,764-183,old

200000000 ,7,69 ,764-183,old

200000000 ,8,69 ,764-183,old

200000000 ,9,69 ,764-183,pending

];

Temp:

Load ANNOTATION as ta,

max(INST_#) as ti

//STATUS as ts

Resident Test

Group by ANNOTATION;

Left join

Load ANNOTATION as ta,INST_# as ti,STATUS as fin_st

Resident Test;

Left Join(Test)

Load ta as ANNOTATION,

ti as INST#,

fin_st as final_status

Resident Temp;

DROP table Temp;

EXIT SCRIPT;

Then In front end

add pivot with SUBSC_NO,ANNOTATION,final_status,INST_#  as dimension

and

sum(AMOUNT) as expression.

Regards,

Prashant

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

6 Replies
MK_QSL
MVP

What is the expression / Calculated Dimension you have used in STATUS?

PrashantSangle

Hi,

I have done it in script.

Test:

LOAD * INLINE [

P_SUBSC_NO,INST_#,AMOUNT,ANNOTATION,STATUS

200000000 ,8 ,15 ,122-235,old

200000000 ,9 ,15 ,122-235,old

200000000 ,10,15 ,122-235,old

200000000 ,11,15 ,122-235,old

200000000 ,12,15 ,122-235,old

200000000 ,13,15 ,122-235,old

200000000 ,14,15 ,122-235,current

200000000 ,4,69 ,764-183,old

200000000 ,5,69 ,764-183,old

200000000 ,6,69 ,764-183,old

200000000 ,7,69 ,764-183,old

200000000 ,8,69 ,764-183,old

200000000 ,9,69 ,764-183,pending

];

Temp:

Load ANNOTATION as ta,

max(INST_#) as ti

//STATUS as ts

Resident Test

Group by ANNOTATION;

Left join

Load ANNOTATION as ta,INST_# as ti,STATUS as fin_st

Resident Test;

Left Join(Test)

Load ta as ANNOTATION,

ti as INST#,

fin_st as final_status

Resident Temp;

DROP table Temp;

EXIT SCRIPT;

Then In front end

add pivot with SUBSC_NO,ANNOTATION,final_status,INST_#  as dimension

and

sum(AMOUNT) as expression.

Regards,

Prashant

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
antoniotiman
Master III

Try to use Calculated Dimension STATUS

=Aggr(If(INST_#=Max(INST_#),STATUS),STATUS)

and Check 'Suppress when value is Null'

Regards

Not applicable
Author

It returns blank results, not an error though

antoniotiman
Master III

tyagishaila
Specialist

Anotonia solution is working well.

You have to use given expression as Calculated Dimension not in Expression.