web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Answered

Problems with if

(0) ShareShare
ReportReport
Posted on by 169

Whats wrong with this Code:

If(
 varIntID=Or("2021a";"2021b";"2021c");
 Refresh('tbl-SuS_Daten-2021a_b_c');;
 Clear(SuSCollection);;
 Collect(SuSCollection;Filter('tbl-SUS';StartsWith(Title;varIntID));;
 If(IsBlankOrError('tbl-SuS_Daten-2021a_b_c');Button3_1.Visible=true;false);

 varIntID=Or("2020a";"2020b";"2020c");
 Refresh('tbl-SuS_Daten-2020a_b_c');;
 Clear(SuSCollection);;
 Collect(SuSCollection;Filter('tbl-SUS';StartsWith(Title;varIntID));;
 If(IsBlankOrError('tbl-SuS_Daten-2020a_b_c');Button3_1.Visible=true;false)
);

But this works:

Refresh('tbl-SuS_Daten-2021a_b_c');;
Clear(SuSCollection);;
Collect(SuSCollection;Filter('tbl-SUS';StartsWith(Title;varIntID));;
If(IsBlankOrError('tbl-SuS_Daten-2021a_b_c');Button3_1.Visible=true;false)

There must be a mistake with the if function!

Thanks for helping

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @chrisegger 

    In PowerApps you cannot set a property with an equal operator. Button3_1.Visible=true is a comparison operation, not an assignment.

     

    Since PowerApps is not a development platform, it gets values by reference and formulas, just like Excel (as it was modeled around Excel).

     

    So, your formula on the button Visible property should be:  IsBlankOrError('tbl-SuS_Daten-2021a_b_c')

     

    Your other formula you posted should be:

    If(
     varIntID in "2021a|2021b|2021c";
     Refresh('tbl-SuS_Daten-2021a_b_c');;
     ClearCollect(SuSCollection; Filter('tbl-SUS'; StartsWith(Title;varIntID));
     
     varIntID in "2020a|2020b|2020c";
     Refresh('tbl-SuS_Daten-2020a_b_c');;
     ClearCollect(SuSCollection; Filter('tbl-SUS';StartsWith(Title;varIntID)) 
    );

     

    I would assume you are refreshing the datasource because this is a multiperson app where others are changing records constantly.  If not, then I would eliminate the Refresh operations as they are performance expensive and not needed.

     

    I hope this is helpful for you.

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Thats a good point for him @RandyHayes  from what I have seen of other aspects of his app, each person will only ever alter their own classes students, so there should be no changing data conflicts and the refresh will not be needed

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @TheRobRush 

    Yes, Refresh is only needed when there will be external (outside of the app...including another copy of the app running) that will alter the datasource and the app needs to have refreshed data of those changes.

    Beyond that, it is not needed.

    And...actually, if you are not referencing the record elsewhere in the app, PowerApps will actually refresh its own record from the datasource if there are changes as soon as you first access it (this is another topic!)

  • chrisegger Profile Picture
    169 on at

    thanks a lot you guys

  • chrisegger Profile Picture
    169 on at

    @TheRobRush 
    Everything would be easier, if I had only one sharepointlist.
    If I would calculate:
    I've got 12 classes with each 25 pupils and each year maybe 20 queries resulted to

    a minimum of 6000 records (a record has 10 columns) (if I clean the list every year)

    Is this not too much??

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Yes and no. Yes in that Powerapps caps out at 2000 items pulling from sharepoint in a single query.

     

    But NO because the way your data needs to be laid out is a simple = filter, = this teachers name 

     

    Check out Sharepoint Delegation in Powerapps to learn moreand Also @WarrenBelz amazing resource of Practical PowerApps so ya, I do not see this being an issue for a simple filter like your data would require.

     

    And then make yourself a Flow, to automate the list cleanup at the end of the year

  • TheRobRush Profile Picture
    11,128 Moderator on at

    or = class number, however you decide to identify them apart from one another

  • chrisegger Profile Picture
    169 on at

    So I can Do IT with only one splists. 

    and How can I clean the list every year automatically? 

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Yes, you can do it with a single list. And the cleaning of the list will be via a flow, done at end of year (Microsoft Power Automate) Will basically set up a scheduled flow, have it run on a specific date, and run a do until it has gotten and removed all the items on your list, and then once it has completed it will go back to sleep until the specified time (In your case 365 days later)

  • chrisegger Profile Picture
    169 on at

    Perfect, I will try. Maybe I ask you later on about the yearly deleting with automate

    thanks a lot 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard