Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
poluvidyasagar
Creator II
Creator II

Front and Back Logic Lookup

Hi,

I am trying to write a script that can help achieve the following. here is the explanation of problem and desired solution.

Problem:

I have 3 tables:

First table: This tables gives information about Area, its station type and its sequence

Area_Table:

AreaStationTypeStationSequence
M1Main1
M2Main2
M3Main3
M4Main4
P1Not-Main1
P2Not-Main2
P3Not-Main3
P4Not-Main4

 

Second Table: This tables gives information about Parts, Area where they are needed and Number of locations needed in the area

PartLocationNeeded:

Part#Area Needed# of Locations in the Needed Area
123M11
123M21
123M41
345M21
345M31
456M31
456M41
567P11
678P21

 

Third Table: This table gives information where part is setup in the area and number of locations setup in that area.

PartLocationExists:

Part#Area Where  Locations Exists# of Locations Exists
123M21
345M31
456M31
567P11
678P21

 

Desired Solution: table below gives desired output i am looking for.I have added comments columns for understanding purpose only

So basically, what i need is to look for each part number and where a location is needed and compare against where the location is setup. If the location is setup in needed station or needed station -1 or needed station +1 , then i am okay. other wise i should flag as NOT GOOD.

For example, Part 123 is needed in M1,M2, M4 stations but part is setup in M2 location only. So going by station sequence,M1 station requirement is satisfied because of Neededstation+1, M2 station requirement is satisfied because of location in needed station but M4 station requirement is not satisfied because no locations in needed station or needed station -1 or needed station +1.

Part#Area Needed# of Locations in the Needed AreaStation SequenceArea Where  Locations Exists# Locations ExistsCheckComments
123M111 0GoodLocations in +1 Station
123M212M21GoodLocations in Same Station
123M414 0Not GoodNo location in -1 ,+1 station range
345M212 0GoodLocations in +1 Station
345M313M31GoodLocations in Same Station
456M313M31GoodLocations in Same Station
456M414 0GoodLocations in -1 Station
567P111P11GoodLocations in Same Station
678P212P21GoodLocations in Same Station

Can someone help me write the logic:

Let me know if you need more details.

Thanks,
Vidya

Labels (1)
6 Replies
Brett_Bleess
Former Employee
Former Employee

Generally this is something that would require services, paid engagement.  The best place I can point you is the Design Blog area to look through the how-to posts there to see if you can find some examples of what you are trying to do there to get you going.

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

Sorry I do not have something better for you.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
Saravanan_Desingh

One solution is.

Area_Table:
LOAD * INLINE [
    Area, StationType, StationSequence
    M1, Main, 1
    M2, Main, 2
    M3, Main, 3
    M4, Main, 4
    P1, Not-Main, 1
    P2, Not-Main, 2
    P3, Not-Main, 3
    P4, Not-Main, 4
];

PartLocationNeeded:
LOAD * INLINE [
    Part#, Area Needed, # of Locations in the Needed Area
    123, M1, 1
    123, M2, 1
    123, M4, 1
    345, M2, 1
    345, M3, 1
    456, M3, 1
    456, M4, 1
    567, P1, 1
    678, P2, 1
];

Left Join(PartLocationNeeded)
LOAD Area As [Area Needed], StationSequence
Resident Area_Table;

PartLocationExists:
LOAD * INLINE [
    Part#, Area Where  Locations Exists, # of Locations Exists
    123, M2, 1
    345, M3, 1
    456, M3, 1
    567, P1, 1
    678, P2, 1
];

Left Join(PartLocationExists)
LOAD Area As [Area Where  Locations Exists], StationSequence As LocSeq#
Resident Area_Table;

Drop Table Area_Table;
Saravanan_Desingh

Dimension: Part#, [Area Needed]

Expressions:

[# of Locations in the Needed Area]
StationSequence
[Area Where  Locations Exists]
[# of Locations Exists]
Check : If(StationSequence=LocSeq# Or StationSequence-1=LocSeq# Or StationSequence+1=LocSeq#, 'Good', 'Not Good')
Saravanan_Desingh

commQV02.PNG

Saravanan_Desingh

One more update to the expression, to match with your output.

[# of Locations in the Needed Area]
StationSequence
[Area Where  Locations Exists] : If(StationSequence=LocSeq#,[Area Where  Locations Exists])
[# of Locations Exists]
Check : If(StationSequence=LocSeq# Or StationSequence-1=LocSeq# Or StationSequence+1=LocSeq#, 'Good', 'Not Good')