Hello, I have dataset that I am trying to add new fields (FM and Status) based on layers of nested ifs which is currently 15 layers deep now using 12 fields. I need the ability to easily add more layers with any combination of the fields. In the table below, blank fields indicate that any value in the dataset is acceptable so long as the other fields are met.
I am currently using 12 different fields in nested ifs, but my dataset has 60+ fields and any of them could potentially be used on future additional ifs.
I don't want to edit the script every time I need to add a new layer. I envision adding another row of conditional values to the table below. The script would essentially review the conditions in the table (and priority) to apply the correct FM and Status value to the master dataset.
I've used Mapping Load and Apply Map in the past, but similarly it is not dynamic, and I’ve had to make a new map for every variant of conditional fields required. For example, rows 8 and 9 could use the same Mapping Load key as shown in Psuedocode below the table. That would still require nested ifs, just not as many (now).
I’ve been using QlikView for about 2 year, but it’s not my primary function and I certainly wouldn’t claim that my approach is the most efficient. Layers and layers of nested ifs does not seem efficient. If you have other recommendations. I’m certainly open to any ideas.
Thanks for your help. Shaun
BA or BB
DA or DE or GA
GA or AA
Shake or Drop
AP or AA
AP or AA
AS or ED
Load Table above
//Excerpt, additional Mapping Loads required for each variant of conditional field combinations
MAP_STATUS_B1: MAPPING LOAD trim(FRCause) & '|' & trim(GrowerType) & '|' & trim(FRImper) AS MAP_KEY, FMstatus AS MAP_DESC Resident FM_STATUSTEMP where len(trim(Fruit))=0 and len(trim(Cause))=0 and len(trim(Color))=0 and len(trim(Loc))=0 and len(trim(ShipDate))=0 and len(trim(PickDate))=0 and len(trim(Harvester))=0 and len(trim(Grower))=0 and len(trim(GrowerLocation))=0 and len(trim(FRCause))>0 and len(trim(GrowerType))>0 and len(trim(FRImper))>0;