cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
FelipeCaru
Level 8

Gallery 1 is used for Gallery 2 filter

Hello all,

I have a problem with two gallery filtering, where one item selected should show only its items on the second one, however, it is showing all. I did try a solution in a different case (https://powerusers.microsoft.com/t5/General-Discussion/Gallery-default-for-input-from-another-galler...), however it did not work.

In my data, I have as source an Excel file as following:

excelSource}.png

On this, my first screen is showing only the first column, "project". First gallery is coded as:

GroupBy(Filter(Consolidado_Piloto, Or(Lower(User().Email)=Lower('PowerApp Admin'), Lower(User().Email)=Lower('Responsable ARQ'), Lower(User().Email)=Lower('Responsable ING')) && Len('Nombre Tarea')>0),"Nombre_x0020_Proyecto","Proyectos")

And by selecting one, it should show only those with the corresponding project. However, when selecting "SBA Longavi" for example, it shows both "ejecución" and "aprobación", where the second one is only for other project. It also shows in count as ALL the "ejecución" of both projects, instead of only counting the ones corresponding to that project.

The code for the second gallery is:

GroupBy(Filter(Consolidado_Piloto, Or(Lower(User().Email)=Lower('PowerApp Admin'), Lower(User().Email)=Lower('Responsable ARQ'), Lower(User().Email)=Lower('Responsable ING')) && 'Nombre Proyecto'=galleryListaProyecto.Selected.Nombre_x0020_Proyecto && Len('Nombre Tarea')>0),"Nombre_x0020_Tarea","Tareas")

Where the filter I tried adding was:

&& 'Nombre Proyecto'=galleryListaProyecto.Selected.Nombre_x0020_Proyecto

Where it showed error: "this rule creates a circular reference between properties, which is not allowed. A property cannot reference itself or other properties affected by its value."

 

What can I do? Any help would be greatly appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Gallery 1 is used for Gallery 2 filter

@FelipeCaru 

Okay, thought it would be easier to take your data and throw together an App to demonstrate this.

 

Please look at the attached App and you will see all the Galleries listed with their appropriate items, correct counts and proper grouping.  No Dependientes columns needed.

 

Look at the OnVisible of the Screen to see the Data structure as you had in your picture.  Obviously I used a collection for this sample rather than an excel file.

Look at the Gallery Items properties and the labels properties to see the formulas needed.

 

Take a look and let me know if you still have questions.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

19 REPLIES 19
Super User
Super User

Re: Gallery 1 is used for Gallery 2 filter

@FelipeCaru 

Your items property for your second Gallery should be this:

galleryListaProyecto.Selected.Proyectos

You are already doing the GroupBy in the first Gallery which is creating the appropriate filter for the second gallery in the Proyectos column...why do it again?  Just reference it.

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
FelipeCaru
Level 8

Re: Gallery 1 is used for Gallery 2 filter

@RandyHayes 

I did try adding it in the filter there like you said, however, keeps saying circular reference error.

GroupBy(Filter(Consolidado_Piloto, Or(Lower(User().Email)=Lower('PowerApp Admin'), Lower(User().Email)=Lower('Responsable ARQ'), Lower(User().Email)=Lower('Responsable ING')) && galleryListaProyecto.Selected.Proyectos && Len('Nombre Tarea')>0),"Nombre_x0020_Tarea","Tareas")
Super User
Super User

Re: Gallery 1 is used for Gallery 2 filter

@FelipeCaru 

Your items property for your second Gallery should be this:

galleryListaProyecto.Selected.Proyectos

Just that, nothing else...

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
FelipeCaru
Level 8

Re: Gallery 1 is used for Gallery 2 filter

@RandyHayes 

Even with it being only that, there is an error of circular reference, with red underscore/error under ".Proyectos".

And the GroupBy in that one is because there are tasks with same name, so avoid having all of same name displayed

Super User
Super User

Re: Gallery 1 is used for Gallery 2 filter

@FelipeCaru 

What is your Items property now for your second Gallery?

What is the name of your first gallery?

The formula you have for your first is:

 

GroupBy(Filter(Consolidado_Piloto, Or(Lower(User().Email)=Lower('PowerApp Admin'), Lower(User().Email)=Lower('Responsable ARQ'), Lower(User().Email)=Lower('Responsable ING')) && Len('Nombre Tarea')>0),"Nombre_x0020_Proyecto","Proyectos")

And for the second?

 

 

You should have:

<yourFirstGalleryName>.Selected.Proyectos

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
FelipeCaru
Level 8

Re: Gallery 1 is used for Gallery 2 filter

@RandyHayes 

I used for my second gallery:

galleryListaProyecto.Selected.Proyectos

The first gallery is called: "galleryListaProyecto", second gallery is called "galleryListaTareas". And even by having for the second gallery that code, keeps saying error of circular reference. Even tried doing:

galleryListaProyecto.Selected.Proyectos.'Nombre Tarea'

And no case, either

Super User
Super User

Re: Gallery 1 is used for Gallery 2 filter

@FelipeCaru 

Your first gallery is a listing of project names (Nombre_x0020_Proyecto).

You user the following groupby to filter and create sub items:

GroupBy(Filter(Consolidado_Piloto, Or(Lower(User().Email)=Lower('PowerApp Admin'), Lower(User().Email)=Lower('Responsable ARQ'), Lower(User().Email)=Lower('Responsable ING')) && Len('Nombre Tarea')>0),"Nombre_x0020_Proyecto","Proyectos")

This will result in a two column table of (distinct) Nombre_x0020_Proyecto and Proyectos (the rest of the record).

 

For your second gallery, you want to display the rest of the information of that record (the group of records that correspond to the Project Name).  Since you are already grouping in the first Gallery, there is no need to Filter anything again, you can just reference the galleryListaProyecto.Selected.Proyectos - which is a table of all the records associtated with that Project Name.

 

This is the normal behavior - something seems to be odd with the second gallery.  

I would recommend throwing another Gallery on the form and setting its Items property to what I mentioned above - you *should not* be seeing any circular reference.

If you dont't then the problem is within your current second gallery...you could either hunt down the circular reference, or just build a new gallery.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
FelipeCaru
Level 8

Re: Gallery 1 is used for Gallery 2 filter

@RandyHayes 

After reloading the app (and close/open), made a new one somewhere else, and it did work by itself. Question, however: I left it as

GroupBy(galleryListaProyecto.Selected.Proyectos,"Nombre_x0020_Tarea","Tareas")

As to show one of them. Question is, do I need to add the filters of the first gallery? Those being:

Or(Lower(User().Email)=Lower('PowerApp Admin'), Lower(User().Email)=Lower('Responsable ARQ'), Lower(User().Email)=Lower('Responsable ING')) && Len('Nombre Tarea')>0

Filter of the 3 users (PA Admin, ARQ, ING) and the "Len(Tarea)>0" as to not show those with empty/blank space.

 

EDIT:
However, the second formula I had on the first (project) gallery is:

Concatenate(Text(CountRows(galleryListaTareas.AllItems)), " sub elementos")

Which was the counter. If I use the galleryListaProyecto.Selected.Proyectos, the formula above will give me a circular reference

Super User
Super User

Re: Gallery 1 is used for Gallery 2 filter

@FelipeCaru 

Yes, sometimes PowerApps gets confused and will not get unconfused except to get out and back in.

No, you do not need to reapply filters because you are not going to the DataSource again...you already did that in your GroupBy formula - now you are using that as your datasource - so it's already filtered, distincted, and grouped.

Everytime you groupby, you will have a table of two or more columns as a result.  The first will be the first group by column (i.e. distinct values) and the second will be the subste of items that have that criteria.

 

So in your case, you have Gallery 1 (galleryListaProyecto) Items:

GroupBy(Filter(Consolidado_Piloto, Or(Lower(User().Email)=Lower('PowerApp Admin'), Lower(User().Email)=Lower('Responsable ARQ'), Lower(User().Email)=Lower('Responsable ING')) && Len('Nombre Tarea')>0),"Nombre_x0020_Proyecto","Proyectos")

From that you will have a distinct column of "Nombre_x0020_Proyecto" and a table in a column called "Proyectos".  You can CountRows on "Proyectos" and you will have a count of how many records are in that table.

So, on each item you can do a CountRows(ThisItem.Proyectos) and it will give you the count of Projects associated with Nombre_x0020_Proyecto

So - CountRows(ThisItem.Proyectos) & " sub elementos"

 

Gallery 2 (galleryListaTareas) Items:

GroupBy(galleryListaProyecto.Selected.Proyectos,"Nombre_x0020_Tarea","Tareas")

This will take your table column of Proyectos from your Selected item on your first Gallery and create another table with two columns - one is the distinct list of "Nombre_x0020_Tarea" and the second column (Tareas) is a table of all the records that are associated with the distinct Nombre_x0020_Tarea.

You can CountRows(ThisItem.Tareas) and it will give you the number of Tareas records in that item.

So, CountRows(ThisItem.Tareas) & " sub tareas"

 

Hope that clears it up.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
thirdimage

Power Platform 24

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (4,879)