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

Filter database

Each person in the Name column has its own Test value. When you click the button, if the person is already listed in the table, then his individual value should increase by one. if he is new, then his name creates a new row with the value Test=1.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Filter database

@Andie 

Another idea for you... I have replaced ISEMPTY with ISBLANK.  This would seem to be the reason for the problem.  I should have changed it when I revised my original answer but missed it.

 

Also, there was a misplaced } bracket in your code within the 2nd patch statement so I repositioned it.

 

ForAll(
    Blue;
    If(IsBlank(LookUp(Таблица3;DisplayName = Blue[@DisplayName]));
    Patch(
        Таблица3;
        Defaults(Таблица3);
        {Имя: Blue[@DisplayName]; Тест: 1}
    );
    Patch(
        Таблица3;
        LookUp(Таблица3; DisplayName = Blue[@DisplayName]);
        {
            Имя: Blue[@DisplayName];
            Тест: LookUp(Таблица3; DisplayName = Blue[@DisplayName]; Тест) + 1)
        }
    )
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

7 REPLIES 7
Highlighted
Super User III
Super User III

Re: Filter database

Can you explain further. Example would help

 

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Super User III
Super User III

Re: Filter database

@Andie
I assume this is a continuation of our previous thread. Here’s my suggestion. Hopefully there are no syntax errors since I typed this on my phone...

ForAll(
    Blue;
    ClearCollect(currentRecord; LookUp(Table3, DisplayName=Blue[@DisplayName]));;
    If(IsEmpty(currentRecord);
    Patch(Table3; Defaults(Table3); {Name: Blue[@DisplayName]; Test: 1});
    Patch(Table3; First(currentRecord); {Name: Blue[@DisplayName]; Test: First(currentRecord).Test + 1})
)


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Frequent Visitor

Re: Filter database

Sorry, I'm probably tired of it already, but I'm getting a bug:

IKdK8to49tY

Writes that the ClearCollect function cannot be applied ForAll... 😑

Highlighted
Super User III
Super User III

Re: Filter database

@Andie 

Earlier I was typing from my phone with no way to test the solution.  My mistake was thinking CLEARCOLLECT could be used inside of FORALL. 

 

Here is my revised solution...  please give it a try and let me know if it works.

ForAll(
    Blue;
    If(IsEmpty(LookUp(Table3, DisplayName=Blue[@DisplayName])));
        Patch(
            Table3;
            Defaults(Table3);
            {Name: Blue[@DisplayName]; Test: 1}
        );
        Patch(
            Table3; 
            LookUp(Table3, DisplayName=Blue[@DisplayName]);
            {Name: Blue[@DisplayName]; Test: LookUp(Table3, DisplayName=Blue[@DisplayName], Test) + 1}
    )
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Frequent Visitor

Re: Filter database

When testing the code, I entered a single name in the Blue collection first. But nothing happened. Next, I entered this name in the Table3 database itself, and when I clicked the button, the Test value changed to 1 - it worked correctly. When entering two names (the first name was already used in the first stages), the second name replaced the string with the first one. For Example, Table3=[Jack; 5], Blue=[Jack,Tom]. Became Table3=[Tom;7]. The new line does not appear, but it is replaced. And the condition doesn't work if the table is empty. P. s. There is an error in your code, your brackets are incorrectly placed, an extra bracket is in the third line, it should be at the end.

I'm from Russia and I'm doing a school project, so Table 3 = Таблица3; Name = Имя; Test = Тест and in our Russian version, you need to put a semicolon everywhere, just a comma does not fit.

 

ForAll(
 Blue;
 If(
 IsEmpty(
 LookUp(
 Таблица3;
 DisplayName = Blue[@DisplayName]
 )
 );
 Patch(
 Таблица3;
 Defaults(Таблица3);
 {
 Имя: Blue[@DisplayName];
 Тест: 1
 }
 );
 Patch(
 Таблица3;
 LookUp(
 Таблица3;
 DisplayName = Blue[@DisplayName]
 );
 {
 Имя: Blue[@DisplayName];
 Тест: LookUp(
 Таблица3;
 DisplayName = Blue[@DisplayName];
 Тест
 ) + 1
 }
 )
 )
)

 

 

Highlighted
Super User III
Super User III

Re: Filter database

@Andie 

Another idea for you... I have replaced ISEMPTY with ISBLANK.  This would seem to be the reason for the problem.  I should have changed it when I revised my original answer but missed it.

 

Also, there was a misplaced } bracket in your code within the 2nd patch statement so I repositioned it.

 

ForAll(
    Blue;
    If(IsBlank(LookUp(Таблица3;DisplayName = Blue[@DisplayName]));
    Patch(
        Таблица3;
        Defaults(Таблица3);
        {Имя: Blue[@DisplayName]; Тест: 1}
    );
    Patch(
        Таблица3;
        LookUp(Таблица3; DisplayName = Blue[@DisplayName]);
        {
            Имя: Blue[@DisplayName];
            Тест: LookUp(Таблица3; DisplayName = Blue[@DisplayName]; Тест) + 1)
        }
    )
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Highlighted
Frequent Visitor

Re: Filter database

 

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 (5,986)