Assigning or pulling inventory numbers from table

Hello Appsheet experts,

I have a spreadsheet that keeps track of spare parts.

Parts are sometimes grouped together and share a common inventory number and Description. So the Description field can be thought of as a category.

When a user wishes to add a new part via the Parts Form, the first thing they fill out is the Description field. This field is a drop-down-style field and has all of the existing Description of parts, with the ability to add an entirely new Description. So, if the user wishes to add another subpart to an existing inventory, (which will have the same inventory #), the expression below pulls the existing Inv number from the spreadsheet. All is well.

When a user wishes to add an entirely new Description (and thereby require a new inventory number), I use MAX to find the highest inventory number already in use, and then add 1 to it.

These expressions seem to work fine individually, but when I try to combine them via an IF statement, I run into a problem. Whenever a user enters a new Description, it appears as though the expression which I use to pull an existing inventory number gets (understandably) confused and "errors out", and the inventory field isn't even displayed.

It's as though I need an IFERROR-style expression that says to continue to the MAX expression (and thereby assign a new inventory number) if the existing Description doesn't exist in the table.

Here's what I have so far.

IF(ANY(SELECT(Parts[Inv], ([Description] = [_THISROW].[Description]))) = "",
Max(Parts[Inv]) + 1,
ANY(SELECT(Parts[Inv], ([Description] = [_THISROW].[Description])))
)

Sample of the spreadsheet below:

 

 

TimestampInvDescriptionDetailsQuantity
     
12/6/2021 14:35:421MiniMax TugChain1
12/6/2021 14:36:421MiniMax TugMaster Link1
12/6/2021 14:37:421MiniMax TugGear Clamps2
12/7/2021 16:15:081MiniMax TugCotter Pins8
12/8/2021 10:02:312Throttle Quadrant ControlsSpare (Red) TOGA Button1
12/16/2021 10:17:172Throttle Quadrant ControlsCowl Flaps Knob1
12/31/2021 11:00:172Throttle Quadrant ControlsMixture Knob1
12/31/2021 10:15:172Throttle Quadrant ControlsThrottle Knob1
12/31/2021 13:31:202Throttle Quadrant ControlsProp Knob1
12/31/2021 13:33:032Throttle Quadrant ControlsLoc-Tite1
12/31/2021 13:34:433Universal Fuel GaugeFuel Stick1
12/31/2021 13:49:193Universal Fuel GaugeFuel Stop1
1/4/2022 12:35:193Universal Fuel GaugeConversion Chart1
1/4/2022 12:37:204Switch Cover - Spare 3D Printed(For Reference)1
1/10/2022 11:10:005Gear Actuator Service KitsNose Gear Kit1
1/4/2022 12:38:035Gear Actuator Service KitsMain Gear Kits2

 

Thanks in advance for any and all assistance!

Solved Solved
0 9 285
1 ACCEPTED SOLUTION

Here's the solution if anyone needs it in the future, I feel like it's worth noting that @steve1123 is using this setup to sort their inventory description by concatenating these inv numbers onto the beginning of the description and sorting them from lowest to highest.

IFS(
IN([_THISROW].[Description] , LIST(PARTS[Description])),
NUMBER(SELECT(Parts[Inv], IN([_THISROW].[Description],LIST([Description])),TRUE)
),
NOT(CONTAINS([_THISROW].[Description] , LIST(PARTS[Description]))),
Max(Parts[Inv])+1
)


For a clean user experience, I recommend changing the Details column to an Enum, deselecting Auto-complete other values and setting the Suggested values to:

SELECT(Parts[Details], ([_THISROW].[Description] = [Description]),TRUE)

 

 

View solution in original post

9 REPLIES 9
Top Labels in this Space