cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FDJCJFC
Frequent Visitor

Filter keeps returning entire list

Hi

Im trying to make a filter within a forall, and it keeps loading the whole list. 

 

I have 2 collections in play:

C_Elementer: 171 parts, which all are tagged with Element

C_Elementer_bestilt: Which elements are there are orders for, currently 1

 

Im trying with this code: 

 

ForAll(C_Elementer_bestilt_f,
        
            Collect(Dele1,             
             Filter(C_Elementer, Element = ThisRecord.Element  )
            );

        Collect(C_Dele_dato, {Dele: Dele1, Leveringsdato:ThisRecord.Leveringsdato}
        )
)
;
ClearCollect(C_alle_dele,Ungroup(C_Dele_dato,"Dele"))

 

 

The problem is, that the Filtering does not happen. It keeps returning all 171 records from C_elementer, although only 8 corresponds with the Element. 

 

I have tried with many different types of Element, but nothings seems to work

 

Any thoughts on this? - 

1 ACCEPTED SOLUTION

Accepted Solutions
theapurva
Responsive Resident
Responsive Resident

Hello, Please try as below:

ForAll(C_Elementer_bestilt_f as LookUpdata,
        
            Collect(Dele1,             
             Filter(C_Elementer, Element = LookUpdata.Element  )
            );

        Collect(C_Dele_dato, {Dele: Dele1, Leveringsdato:LookUpdata.Leveringsdato}//**
        )
)
;
ClearCollect(C_alle_dele,Ungroup(C_Dele_dato,"Dele"))

** PLease check this line once as I am not able to relate the relation:

 

----------------------------------------------------------------------------------------------------------------------
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!

View solution in original post

4 REPLIES 4
theapurva
Responsive Resident
Responsive Resident

Hello, Please try as below:

ForAll(C_Elementer_bestilt_f as LookUpdata,
        
            Collect(Dele1,             
             Filter(C_Elementer, Element = LookUpdata.Element  )
            );

        Collect(C_Dele_dato, {Dele: Dele1, Leveringsdato:LookUpdata.Leveringsdato}//**
        )
)
;
ClearCollect(C_alle_dele,Ungroup(C_Dele_dato,"Dele"))

** PLease check this line once as I am not able to relate the relation:

 

----------------------------------------------------------------------------------------------------------------------
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!

Thank you, works like a charm. - Literally just saved my day 😉

iAm_ManCat
Super User
Super User

I think the issue is likely that you need to disambiguate between your datasources and check fi the matching record is blank - it looks like it was collecting every row for your c_Dele_dato even if there was no matching element:

 

 

ForAll( C_Elementer_bestilt_f,
        //If the record matching is not blank then collect it, otherwise do not collect (it was collecting even blanks before)
        If(!IsBlank(LookUp(C_Elementer, [@C_Elementer].Element = ThisRecord.Element).Element),
            Collect(
                    Dele1,             
                    Filter(C_Elementer, [@C_Elementer].Element = ThisRecord.Element)
            );
            Collect(
                    C_Dele_dato,
                    {
                        Dele: Dele1, 
                        Leveringsdato:ThisRecord.Leveringsdato
                    }
          )
       )
);
ClearCollect(C_alle_dele,Ungroup(C_Dele_dato,"Dele"))

 

 

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Ignore this, I see you got a fix already 🙂

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,899)