Dependent App Formula

Hi, Iโ€™m trying to make an App formula in a form field that returns data from another table based on the answer to a previous question. In other words, I have three teams and if I answer Team 1 to the first question, I want it to automatically fill this field with info from a slice I made of people who are on Team 1. I feel like Iโ€™m close, but need a little more guidance. Thanks!

Solved Solved
0 14 692
1 ACCEPTED SOLUTION

Correct

Then you can use this expression:

//Assuming that you have 5 location columns
//You can alter the expressions as per needs
SWITCH(
	[Location],
	"KeyColumnValueForLocation_1",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location1]>0)),
	"KeyColumnValueForLocation_2",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location2]>0)),
	"KeyColumnValueForLocation_3",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location3]>0)),
	"KeyColumnValueForLocation_4",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location4]>0)),
	SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location5]>0)) //Default value
)

View solution in original post

14 REPLIES 14

ANY(SELECT(AnotherTable[ReturnValueColumn],[LookupColumn]=[_THISROW].[LookupValueColumn]))

OR

LOOKUP([_THISROW].[LookupValueColumn],โ€œAnotherTableโ€,โ€œLookupColumnโ€,โ€œReturnValueColumnโ€)

Hey, when I used the ANY or LOOKUP expressions it only returned one personโ€™s value where I want it to basically return an Enumlist separated by commas.
I used this expression
IF([Team]=โ€œTeam 1โ€, Personnel List Team is Team 1[Personnel ID], IF([Team]=โ€œTeam 2โ€, Personnel List Team is Team 2[Personnel ID], Personnel List[Personnel ID]))
And so far it works pretty well but I understand that Iโ€™ll have to keep repeating the formula for when I add more teams. Any advice to simplify this?

@Luke_Vancleave

To return a list:

SELECT(
	AnotherTable[ReturnValueColumn],
	[LookupColumn]=[_THISROW].[LookupValueColumn]
)

I have a follow up question to this. I have a similar situation in a later part of the form where I previously selected a Site from a REF and then want an ENUMLIST to display a slice of what is at that Site. How do I have it return a slice based on what I previously selected and not just a value from another table?

@Luke_Vancleave
Can you please elaborate your idea about โ€œโ€ฆreturn a slice based on what I previously selected and not just a value from another tableโ€ฆโ€?

Sure! So I have a Large table of tools. Thereโ€™s around 100 columns of data for each row saying the quantity at various locations. To make it easier to view, I made Slices of that table so I can view only what is at those locations.
Iโ€™m making a form that asks what location the user worked at that day and to select which tools at that site they used.
I have a separate table of locations listed too that I use for other purposes.
Iโ€™d like to have the form work so when the user chooses the Location based on a REF to that table, it fills in an ENUMLIST using the Slice of what was at that location for the user to select.

@Luke_Vancleave
I believe below expression should suffice though, however Iโ€™m now aware of your sheet and ref tableโ€™s structure so it might not be an exact fit for you

SELECT(ToolsTable[ToolName],[Location]=[_THISROW].[Location])

So this is saying to display all the Tools from the ToolsTable if their Location column equals what I entered in the formโ€™s previous question?

My table of tools doesnโ€™t have a single location column because different quantities of each tool might be at different locations. For example, there might be 5 "Hammer"s at location one, 2 "Hammer"s at location two, and 0 "Hammer"s at location three. So because there might be different quantities of the same tool at different locations, each tool has columns for โ€œQuantity at location 1โ€, โ€œQuantity at location 2โ€, โ€œQuantity at location 3โ€ and so on.

Maybe I could have an expression that says IFS(The previous entry selected Location1, Filter the tool table to only show rows where the โ€œ[Quantity at location 1]>0โ€, and then write the same for each location?

Correct

Then you can use this expression:

//Assuming that you have 5 location columns
//You can alter the expressions as per needs
SWITCH(
	[Location],
	"KeyColumnValueForLocation_1",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location1]>0)),
	"KeyColumnValueForLocation_2",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location2]>0)),
	"KeyColumnValueForLocation_3",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location3]>0)),
	"KeyColumnValueForLocation_4",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location4]>0)),
	SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Quantity at Location5]>0)) //Default value
)

Thatโ€™s outstanding! Thank you.
So just for my understanding of whatโ€™s going on here, Iโ€™m telling this ENUMLIST to switch what it is displaying by filtering from my ToolsTable based on the [quantity at location column] depending on what I had selected previously?

@Luke_Vancleave
Thatโ€™s correct

Iโ€™m sorry to keep doing this, but every time I learn more it opens a door to something else that I could do.
Letโ€™s say I have another question on my form after I enter a location that also filters the list by asking if the items are an Asset or Consumable which all tools have in one column. How could I add this into the equation too so that it filters the list based one the location and type I selected previously?

@Luke_Vancleave
Please check

//Assuming that you have 5 location columns
//Filtering the tools as per location, type and related quantity
SWITCH(
	[Location],
	"KeyColumnValueForLocation_1",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Type]=[_THISROW].[Type],[Quantity at Location1]>0)),
	"KeyColumnValueForLocation_2",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Type]=[_THISROW].[Type],[Quantity at Location2]>0)),
	"KeyColumnValueForLocation_3",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Type]=[_THISROW].[Type],[Quantity at Location3]>0)),
	"KeyColumnValueForLocation_4",SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Type]=[_THISROW].[Type],[Quantity at Location4]>0)),
	SELECT(ToolsTable[ToolName],AND([Location]=[_THISROW].[Location],[Type]=[_THISROW].[Type],[Quantity at Location5]>0)) //Default value
)

I need to rephrase.
I have three questions to filter and select from. The first is Location which filters what Items I can select, which then filter what Actions I can do to them.


I need help with writing an expression for the suggested values for the Actions, based off what location and Item I selected.
I have a column in each of their tables for the Type that they are. I only want the Actions to โ€œUse Quantityโ€ To appear if Iโ€™ve selected an Item with the Type: Consumable. And I only want the actions to โ€œReport as brokenโ€ to appear if Iโ€™ve selected an Item with the Type: Asset. And I want the actions to โ€œAddโ€ and โ€œSubtractโ€ to appear for both because they are General.

Sorry, I hope Iโ€™m being clear with what Iโ€™m trying to do.

Top Labels in this Space