Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
arusanah
Creator II
Creator II

logic help

A
Null
Null
Null

C

I have a field as above  . this is for cust ID =1 , I wan to store after null value i.e "C" in new column . the logic I am applying is not working .


If([CUST_ID] = Previous([CUST_ID])

  and (isnull(Previous([GRP]))  and RecNo()<>1   ) ,

                                IF (ISNULL([GRP]),0,[GRP])) as [NEW_GRP]



Any help is greatly appreciated !

6 Replies
sunny_talwar

What is CUST_ID and GRP here?

jonathandienst
Partner - Champion III
Partner - Champion III

This is a simplification of your expression:

If([CUST_ID] = Previous([CUST_ID]) And IsNull(Previous([GRP])), If(IsNull(GRP), 0 GRP), 0) as [NEW_GRP]

or

If([CUST_ID] = Previous([CUST_ID]) And IsNull(Previous([GRP])), If(IsNull(GRP), 0 GRP), GRP) as [NEW_GRP]


But I am not sure what you are trying to achieve. I suggest that you provide a more complete example with source data, explaining clearly and exactly what output you would like.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
arusanah
Creator II
Creator II
Author

with The expression you sent , its just eliminating null values in the Grp column  and copying  other   values  into new grp . where as my requirement is to store only  value that is diaplayed  after null in new group.

   

idgrp
1ANew group should contain only
1nullC
1nullD
1null
1C
2B
2B
2Null
2D

where as my requirement is to store only  value that is displayed  after null in new group.

arusanah
Creator II
Creator II
Author

Hi Sunny ,

CUST_ID  is recipient id & Grp is Plan   they are in. person can  move from one plan to another. so in new field we want to store information of the grp where he moved to .

Digvijay_Singh

if you are always storing the last value, then u can try this script -

Source:

Load * inline [

id, grp

1, A

1, null

1, null

1, null

1, C

2, B

2, B

2, Null

2, D ];

NoConcatenate

Final:

Load id,SubField(grp,',',-1) as grp;

Load

  id,concat(grp,',',RecNo()) as grp

resident Source

group by id

  ;

drop Table Source;

maxgro
MVP
MVP

My idea (hope to understand your question) in the attachment

1.png