cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Filter Gallery with toggle and by value of label

Hi everybody

I'm trying to filter a gallery in my app by an toggle and also by the value of an label inside the gallery.

The label is not a part of the data source in the gallery, it is a calculated value based on items in another datasource (the gallery beneath).

I'm trying to filter it by the column on the far right (2, 0, 0, 0) and the toggle. It is calculated by the number of slots with the status "Booked" in the lower gallery. 

 

I only want to show the groups where there are items with status Booked. So when the toggle is "on" it should only show the items in the gallery where the number is greater than 0. 

 

I've tried a lot of formulas but always get the circular reference error, because the label is dependent on the gallery...

 

Can anybody help me with this?

 

Best regards

Eva

 

2020-09-28_11-25-48.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Filter Gallery with toggle and by value of label

Hi @evalindag ,

Do you mean that:
1)gallery1 is used to display the grouped items (greoup by groupid);

2)"2 0 0 0" is calculated value based on the number of booked items in that group;

3)gallery2 is used to display all the items;

4)you want gallery1 only display the groups that the number is greater than 0 when you turn the toggle on?

If so, please do not filter based on the label value. Label value is calculated value, if you use it directly to filter it will lead to circular reference.

Could you tell me the formulas in gallery1 and gallery2?
If gallery1's and gallery2's data source is the same table, you could set gallery1's Items like this:

If(Toggle1.Value,
Filter(
       AddColumns(
           GroupBy(tablename,"GroupID","items"),
           "bookednum",
           CountRows(Filter(items,Status="Booked"))
                  ),
      bookednum>0
      ),
GroupBy(tablename,"GroupID","items"),
           "bookednum",
           CountRows(Filter(items,Status="Booked"))
         )
)

If If gallery1's and gallery2's data source is not the same table, you could set gallery1's Items like this:

If(Toggle1.Value,
    Filter(
           AddColumns(
                      table1,
                     "bookednum",
                     CountRows(
                               Filter(table2,GroupID=table1[@GroupID],Status="Booked")
                               )
                      ),
           bookednum>0),
AddColumns(table1,
           "bookednum",
            CountRows(Filter(table2,GroupID=table1[@GroupID],Status="Booked"))
           )
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Filter Gallery with toggle and by value of label

Hi @evalindag ,

Do you mean that:
1)gallery1 is used to display the grouped items (greoup by groupid);

2)"2 0 0 0" is calculated value based on the number of booked items in that group;

3)gallery2 is used to display all the items;

4)you want gallery1 only display the groups that the number is greater than 0 when you turn the toggle on?

If so, please do not filter based on the label value. Label value is calculated value, if you use it directly to filter it will lead to circular reference.

Could you tell me the formulas in gallery1 and gallery2?
If gallery1's and gallery2's data source is the same table, you could set gallery1's Items like this:

If(Toggle1.Value,
Filter(
       AddColumns(
           GroupBy(tablename,"GroupID","items"),
           "bookednum",
           CountRows(Filter(items,Status="Booked"))
                  ),
      bookednum>0
      ),
GroupBy(tablename,"GroupID","items"),
           "bookednum",
           CountRows(Filter(items,Status="Booked"))
         )
)

If If gallery1's and gallery2's data source is not the same table, you could set gallery1's Items like this:

If(Toggle1.Value,
    Filter(
           AddColumns(
                      table1,
                     "bookednum",
                     CountRows(
                               Filter(table2,GroupID=table1[@GroupID],Status="Booked")
                               )
                      ),
           bookednum>0),
AddColumns(table1,
           "bookednum",
            CountRows(Filter(table2,GroupID=table1[@GroupID],Status="Booked"))
           )
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Helper I
Helper I

Re: Filter Gallery with toggle and by value of label

Hi @v-yutliu-msft 

Thank you so very much, your solution worked! 🙂

They are different sources, so I used the second solution you suggested

 

Best regards

Eva

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (9,915)