cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PierreGiusti
Advocate III
Advocate III

Filter-Order by Lookup field - Common Data Model

Hi there, I've tried some solutions posted in the community but can't make a filter work.

 

In Common Data I had created two tables, one for register the offices of the company (A) and another for the reservations (B) for meetings (1->N), related by ID.

 

Plus the conditions that of the topic "Filter OK", I need to filter and order the gallery of table (B) also by the name of the office (table (A)), but couldn’t make work.

 

Filter OK:

BrowseGallery1.Items:

SortByColumns(If (ActivaFecha.Value = true; Filter('RS Reserva Sala'; (FechaHoraIni >= DatePicker1.SelectedDate) && ((FechaHoraIni)-1 < DatePicker1.SelectedDate) && (Estado <> "Cancelada")); Filter('RS Reserva Sala';FechaHoraIni >= Today() && Estado <> "Cancelada"));"FechaHoraIni";Ascending)

 

Filter that I'm try to make work:

BrowseGallery1.Items:

Filter ( 'RS Reserva Sala';LookUp('RS Registro Salas';PrimaryId = 'RS Reserva Sala'.RS_RegistroSalas_;Sala) = Dropdown1.Selected.Value)

 

Finally, I think to need this:

BrowseGallery1.Items:

SortByColumns(If (ActivaFecha.Value = true; Filter('RS Reserva Sala'; (FechaHoraIni >= DatePicker1.SelectedDate) && ((FechaHoraIni)-1 < DatePicker1.SelectedDate) && (Estado <> "Cancelada") && (LookUp('RS Registro Salas';PrimaryId = 'RS Reserva Sala'.RS_RegistroSalas_;Sala) = Dropdown1.Selected.Value)); Filter('RS Reserva Sala';FechaHoraIni >= Today() && Estado <> "Cancelada") && (LookUp('RS Registro Salas';PrimaryId = 'RS Reserva Sala'.RS_RegistroSalas_;Sala) = Dropdown1.Selected.Value)); (LookUp('RS Registro Salas';PrimaryId = 'RS Reserva Sala'.RS_RegistroSalas_;Sala);Ascending; "FechaHoraIni";Ascending)

 

 

IMAGE1 - The description "MAD-sala 1" that you can see is a result of this lookup: Heading1.Text: LookUp('RS Registro Salas';PrimaryId = ThisItem.RS_RegistroSalas_.PrimaryId).Sala

This Filter is workingThis Filter is working

IMAGE2

This isn´tThis isn´t

Thank you very much.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi, Actually, I figure out that in this case is not necessary a lookup function, because it is possible to use the Dropdown control in a different way.

In my case, the solution was:

 

Situation:

I create tables on Common Data Service.

TABLE_A have 1 line, instead TABLE_B have N lines, related by ID.

The field TABLE_B.RS_RegistroSalas_ is a lookup field who relate with TABLE_A.PrimaryId

I want to filter TABLE_B by the description save in TABLE_A.

 

Solution 1:

Insert a Dropdow object and put on the Item: TABLE_A and the data parameter Value to: Description (in my case, the name of the field is “Sala”)

 

In the gallery of TABLE_B I inserted the follow formula to filter by date or by description of TABLE_A:

 

SortByColumns

(If (ActivaFecha.Value = true;

Filter(TABLE_B; (FechaHoraIni >= DatePicker1.SelectedDate) && ((FechaHoraIni)-1 < DatePicker1.SelectedDate) && (Estado <> "Cancelada"));

Filter('TABLE_B;RS_RegistroSalas_.PrimaryId = Dropdown1.Selected.PrimaryId));"FechaHoraIni";Ascending)

 

<> Image - could't insert

 

Solution 2:

I inserted another gallery calls Gallery_Salas_In and select TABLE_A on it, also use a search box to filter by description:

SortByColumns( Search('TABLE_A';TextSearchBox1.Text;"Sala");"Sala";Ascending)

 

In a gallery of TABLE_B I use the follow filter

SortByColumns(

If (ActivaFecha.Value = true;

Filter('RS Reserva Sala';(FechaHoraIni >= DatePicker1.SelectedDate) && ((FechaHoraIni)-1 < DatePicker1.SelectedDate) && (Estado <> "Cancelada ") && RS_RegistroSalas_.PrimaryId in Gallery_Salas_In.AllItems.PrimaryId );

Filter('RS Reserva Sala';FechaHoraIni >= Today() && Estado <> "Cancelada" && RS_RegistroSalas_.PrimaryId in Gallery_Salas_In.AllItems.PrimaryId)); "FechaHoraIni";Ascending)

 

Thank you.

View solution in original post

2 REPLIES 2
v-yamao-msft
Community Support
Community Support

Hi PierreGiusti,

 

I am not sure the with column “Sala”. Which data source it belongs to?


When you click the yellow triangle, what error message do you get?


I assume that there might be something wrong with your Lookup function, and the error should be “The property expects Text value, but this rules produces incompatible Record values”. If you are getting this error, please try to modify the Lookup function so that it can get a Text value.


And about Lookup function, please see this documentation for more details:
https://powerapps.microsoft.com/en-us/tutorials/function-filter-lookup/

 

 

Best regards,
Mabel Mao

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

Hi, Actually, I figure out that in this case is not necessary a lookup function, because it is possible to use the Dropdown control in a different way.

In my case, the solution was:

 

Situation:

I create tables on Common Data Service.

TABLE_A have 1 line, instead TABLE_B have N lines, related by ID.

The field TABLE_B.RS_RegistroSalas_ is a lookup field who relate with TABLE_A.PrimaryId

I want to filter TABLE_B by the description save in TABLE_A.

 

Solution 1:

Insert a Dropdow object and put on the Item: TABLE_A and the data parameter Value to: Description (in my case, the name of the field is “Sala”)

 

In the gallery of TABLE_B I inserted the follow formula to filter by date or by description of TABLE_A:

 

SortByColumns

(If (ActivaFecha.Value = true;

Filter(TABLE_B; (FechaHoraIni >= DatePicker1.SelectedDate) && ((FechaHoraIni)-1 < DatePicker1.SelectedDate) && (Estado <> "Cancelada"));

Filter('TABLE_B;RS_RegistroSalas_.PrimaryId = Dropdown1.Selected.PrimaryId));"FechaHoraIni";Ascending)

 

<> Image - could't insert

 

Solution 2:

I inserted another gallery calls Gallery_Salas_In and select TABLE_A on it, also use a search box to filter by description:

SortByColumns( Search('TABLE_A';TextSearchBox1.Text;"Sala");"Sala";Ascending)

 

In a gallery of TABLE_B I use the follow filter

SortByColumns(

If (ActivaFecha.Value = true;

Filter('RS Reserva Sala';(FechaHoraIni >= DatePicker1.SelectedDate) && ((FechaHoraIni)-1 < DatePicker1.SelectedDate) && (Estado <> "Cancelada ") && RS_RegistroSalas_.PrimaryId in Gallery_Salas_In.AllItems.PrimaryId );

Filter('RS Reserva Sala';FechaHoraIni >= Today() && Estado <> "Cancelada" && RS_RegistroSalas_.PrimaryId in Gallery_Salas_In.AllItems.PrimaryId)); "FechaHoraIni";Ascending)

 

Thank you.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,304)