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

Straight table if() statements

Hello all, this is my first post and I am fairly new to QlikView so please bear with me.

I have a set of information illustrated by the table below, I have labelled them A, B & Boolean so hopefully the answer will apply to more people than just my specific case.

Field A

Field BBoolean
A1B11
A1B20
A1B30
A1B41
A2B11
etcetcetc

In my application though, Field A is basically a project number, Field B is a project phase and the boolean is whether or not that phase is complete.

Basically what I need is to be able to say 'If B2 is not complete AND B1 is complete then B2 is due' So that the output would look something like:

Field A

Field BIs it Due
A1B2Due
etcetcetc

I thought something like:

=if(FieldB='B2' AND Boolean = 0, if(FieldA='B1' AND Boolean = 1, 'Due', 'Not Due'))

But I think I'm on completely the wrong track, do I need to load the information differently?

Hopefully this is clear enough, and I'm not asking too stupid a question

18 Replies
PrashantSangle

Hi,

I am no sure that i am understand clearly but as you say,

"If B2 is not complete AND B1 is complete then B2 is due"

I means you are evaluating value for FieldB only because there is no B2 in fieldA and You have to compare with your previous field only

Then use previous() in your script like,

if(FieldB='B2' AND Boolean = 0, if(Previous(FieldB)='B1' AND Previous(Boolean) = 1, 'Due', 'Not Due'),'Not Due') as [Is it Due],

Hope this will help you,

Regards,

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 🙂
menta
Partner - Creator II
Partner - Creator II

You can try something like this

T:

LOAD * Inline

[

FieldA,FieldB,Boolean

A1, B1, 1

A1, B2, 0

A1, B3, 0

A1, B4, 1

A2, B1, 1

etc, etc, etc

]

;

load

FieldA,

FieldB,

Boolean,

if(Peek(FieldA)=FieldA, if(Peek(Boolean)=1 and Boolean=0,'Due','Not due') ) as FlagNew,

if(Boolean = 0,'Due','Not Due') as Flag

Resident T;

DROP Table T;

Not applicable
Author

I think something like this should resolve your question:-

aggr(if(Boolean=0,'Due','Complete'),FieldB,FieldA)

SunilChauhan
Champion II
Champion II

may be you looking this


=if(FieldB='B2' AND Boolean = 0,'Due', if(FieldA='B1' AND Boolean = 1,'Due' , 'Not Due'))


hope this helps




Sunil Chauhan
Not applicable
Author

Just looking at the documentation for aggr() and I think this is probably where I should be looking. So thanks for this!

The example you posted isn't quite right but it definitely seems like a step in the right direction

I will look into this further, if it solves it I will let you know

Not applicable
Author

This seems to be evaluating based on Field A being B1 at some stage. This would never be the case. Perhaps seeing the data like this might help:

Proj #

PhaseStatus
1001PAY11
1001PAY20
1001PAY30
1002PAY11
1002PAY21

When PAY1 is complete for a project, PAY2 is due. But PAY3 is not due until PAY2 is complete.

So I want to add a column using an expression to get the below effect:

Proj #

PhaseStatusDue
1001PAY11-
1001PAY20Due
1001PAY30-
1002PAY11-
1002PAY21-
Not applicable
Author

I seem to be nearly there, using the aggr() function using the above field names I have the following:

aggr(if(Boolean = 0 AND above(Boolean) = 1, 'Due', '-')FieldA, FieldB)

I'm going to mark this as correct, I have some issues with my data now but I think they are unique to my data so irrelevant to the community

Thanks for everyone's help big or small

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I'm not sure why you need the aggr(). If you make the dimensions FieldA & FieldB then:

=if(NOT Boolean AND Above(Boolean), 'Due', '')

-ob

Not applicable
Author

Yes of course, how stupid of me. While looking into aggr() I found above(), and just used it in what I already had. Rather than rethinking it!!

Thanks!