cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MattyH
Continued Contributor
Continued Contributor

Limiting results to specific locations

I am currently building an app where we have a number of items in a number of sheds, and those sheds are in several different geographic locations.

 

I currently have a list which shows all of the sheds, but I only want our users to see the sheds that are in certain locations.  Is there a way to do this?

 

My current formula to show all the sheds is below.

 

SortByColumns(Search(Barns, TextSearchBox1.Text, "chorus_name"), "chorus_name", If(SortDescending1, Descending, Ascending))

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
TimRohr
Solution Sage
Solution Sage

Where is your data located? SharePoint list? Common Data Service?

Do you have a relationship between the regions and the sheds established in the way you house your data (ie, a LookUp field)?

 

How you answer that will impact the language of a potential solution.

 

That said, from a general perspective, you have a couple of options...

 

1) If you had a Gallery of Regions, you could pick one and navigate to a screen that listed the Sheds for the Region (another Gallery). Once you picked the Shed, you would see the Things related to that shed. In this case,  your Sheds gallery would have a Filter() statement in the Item property that limited it to some chosen Region (either pre-chosen or user-selected from a dropdown). Then the Things Gallery would have a Filter() that limited them to those associated with the chosen Shed.

 

2) If you want to do it all in one statement, you could provide a dropdown for the Region (user-selected) or you could pre-define the Region (perhaps based on the user's location). Then you can use a statement that would show all the items from the sheds in that region. Building from the inside out, that would be:

Filter(Sheds, RegionID = yourRegionSelection)

----gets the sheds in the selected Region

Filter(Things, ShedID In (previousFilterStatement).ShedID)

----gets the Things in any of the Sheds returned by the interior Filter() statement (the first one, above).

 

If that doesn't get you there, post back and give us more information about the structure of your data.

 

 

View solution in original post

7 REPLIES 7
TimRohr
Solution Sage
Solution Sage

Where is your data located? SharePoint list? Common Data Service?

Do you have a relationship between the regions and the sheds established in the way you house your data (ie, a LookUp field)?

 

How you answer that will impact the language of a potential solution.

 

That said, from a general perspective, you have a couple of options...

 

1) If you had a Gallery of Regions, you could pick one and navigate to a screen that listed the Sheds for the Region (another Gallery). Once you picked the Shed, you would see the Things related to that shed. In this case,  your Sheds gallery would have a Filter() statement in the Item property that limited it to some chosen Region (either pre-chosen or user-selected from a dropdown). Then the Things Gallery would have a Filter() that limited them to those associated with the chosen Shed.

 

2) If you want to do it all in one statement, you could provide a dropdown for the Region (user-selected) or you could pre-define the Region (perhaps based on the user's location). Then you can use a statement that would show all the items from the sheds in that region. Building from the inside out, that would be:

Filter(Sheds, RegionID = yourRegionSelection)

----gets the sheds in the selected Region

Filter(Things, ShedID In (previousFilterStatement).ShedID)

----gets the Things in any of the Sheds returned by the interior Filter() statement (the first one, above).

 

If that doesn't get you there, post back and give us more information about the structure of your data.

 

 

View solution in original post

MattyH
Continued Contributor
Continued Contributor

Thanks for the information.

 

To be honest that was what I thought would be required, I was hoping to get it all filtered with as few clicks as possible in the app itself.

 

I will go back to the double level of filtering, as per your first suggestion.

 

Thanks.

The second option certainly reduces the clicks... but it produces the specific output of all Things in all Sheds in the selected Region.

 

In your best user-interaction scenario, what would the behavior look like? The user would click on... what... and what would they get as the result?

Drrickryp
Super User II
Super User II

Hi @MattyH,

you can prefilter your dataset before searching it if you have a column called locations, for example.

SortByColumns(Search(Filter(Barns, Location = And(“Paris”,”Rome”,”Chicago”), TextSearchBox1.Text, "chorus_name"), "chorus_name", If(SortDescending1, Descending, Ascending))
MattyH
Continued Contributor
Continued Contributor

As an example, say we have 5 locations, A, B, C, D & E.

I want our users to only be able to see those sheds in locations A, B, and C.

They would then be able to click on the required shed from one of those three areas, and view and eventually edit any and all items within that shed.

The sheds in locations D & E are not required to be shown at all in this app.

I'd really discourage handling app-level, ad hoc lists of "include this" entries. They are messy to update, and a nightmare to maintain. If it were me, I would add a yes/no field in my data source that represented whether that item should be included in a given app or app group. Tick A, B, and C to be true/yes, and then set your initial Filter() to validate that field:

 

Filter(Locations, IncludeForShedSearch = true)

 

Then filter your Sheds where the LocationID is in that returned set (as discussed, above).

 

Like I said... just how I would do it. YMMV.

MattyH
Continued Contributor
Continued Contributor

@TimRohr,

 

Thanks for the suggestion, but I am not currently in a position where we can add fields to the data source. It may be something we can look at in the future, but not possible at the moment.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (40,632)