I am in part refining an earlier question to try to ask something tangible here. To frame the issue, I have a somewhat large data set (ca. 250k rows) where I need to transform a given concatenated field into an output for each line item based on whether or not a certain string of text was found within the field. This has been managed in Excel previously (using IF(IFERROR(FIND())), but the formula is too taxing on Excel and I need to move the entire process to Access to better automate it. The end goal is to generate a single table that can paste into an Excel model which then refreshes off the revised date.
Existing SQL:
SELECT my_field_1 ,
my_field_2,
my_field_3,
IIF(Active = 'Yes' AND Issue IS NULL,'OK',
IIF(Issue LIKE '123','123',
IIF(Issue LIKE'234','234',
IIF(Issue LIKE '345','345',
//* Etc going down to 14 nested IIF statements in the above format and
//* returning NULL where conditions are not met. I then roll up the 3 issue
//* sets as follows
IIF(IssueSet1 IS NOT NULL, IssueSet1,
IIF(IssueSet2 IS NOT NULL, IssueSet2,
IIF(IssueSet3 IS NOT NULL, IssueSet3,
'Check for errors')))
Desired output
',123,234' should return '123' in a successful query output into column RollUp.
The hierarchy as it stands is split into 2 sets of 14 nested IIF statements in the above format with a 3rd set of 4 nested IIF statements. I then roll up all the IIF statements as above. Unfortunately, Access is returning ca. 20k NULL items where an earlier IIF is being triggered before a later IIF on the same row, e.g. 1 row meets conditions for 2 of the IIFs, which is inevitable as I need to use this hierarchy to 'prioritise' the more pressing issues further up in the hierarchy.
Problems:
Where the hierarchy triggers '123' first but then '234' follows on the same line item, it returns NULL instead of returning 123. Is there any way I can get this to stop occurring so anything further up in a hierarchy trumps anything below it? This would work fine in a CASE statement if I could do this on a platform other than Access which is very frustrating.
The existing format is clunky and I would prefer to use a lookup column and a permanent table but I cannot figure out how to return only the value I need (e.g. '123') and not the entire field (e.g. ',123,234,345,456')
I need to ultimately generate a summary output that can easily be copy and pasted into quite an Excel model (or input automatically via VBA) which gives Issue ID (IIF generated), Category (already exists), Sub-Category (Already exists), Count (sum grouped on Issue ID, Category and Sub-Category which I can do myself if I sort this IIF problem).
Many thanks and I hope this clarifies what I am trying to do.
J
Likes work as equality operators because you are not using any wildcards. If you meant to say "begins with 123," that's'123*'. - GSerg123can occur anywhere in the string, an equality operator will most certainly not find anything. "Anywhere in the string" is'*123*'. - GSerg