cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Andie
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

@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
eka24
Super User III
Super User III

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.

mdevaney
Super User III
Super User III

@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."

Andie
Frequent Visitor

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

IKdK8to49tY

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

@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."

Andie
Frequent Visitor

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
 }
 )
 )
)

 

 

@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

Andie
Frequent Visitor

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,253)