cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver I
Resolver I

Error on ClearCollect

Hi.

 

I've been following a tutorial on how to build powerapps, but when I paste 

 

ClearCollect(CityPopulations, {City:"London", Country:"United
Kingdom", Population:8615000}, {City:"Berlin",
Country:"Germany", Population:3562000}, {City:"Madrid",
Country:"Spain", Population:3165000}, {City:"Rome",
Country:"Italy", Population:2874000}, {City:"Paris",
Country:"France", Population:2273000}, {City:"Hamburg",
Country:"Germany", Population:1760000}, {City:"Barcelona",
Country:"Spain", Population:1602000}, {City:"Munich",
Country:"Germany", Population:1494000}, {City:"Milan",
Country:"Italy", Population:1344000})

 

into the OnSelect property of the button (as suggested by the tutorial) I get an error saying the name 'CityPopulations' isn't valid and the indicator is not recognised. Any idea why or how to fix it?

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks for your reply! I just opened the project with the error again, and now it works without the error! I don't think I've made any changes since last time I tried that tutorial section. How strange... Anyway, thank you both for your effort! 😊

View solution in original post

6 REPLIES 6
Dual Super User III
Dual Super User III

That's because the CityPopulations collection doesn't exist yet until you press the button.  Run the app in test mode and press the button.  When you exit the error will go away.  or put the following in your App Onstart and run it once.

ClearCollect(CityPopulations, {City:"London", Country:"United
Kingdom", Population:8615000})

  That will create the initial collection. 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thank you for replying! I tried that but the error is still there. Does it work for you if you follow the steps in the page I linked to?

Dual Super User III
Dual Super User III

As I said, you will get that error until the collection is created the first time.  But after that it should go away.  I put the code you had in your post into a button OnSelect and it works fine for me.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Strange, I followed the tutorial step by step (including clicking the button to create the collection) and still got the error. I even tried to create a new powerapp, but still no luck. 

Hi @9kMan :

I made a same test but did not encounted the problem you mentioned.

Could you provide a screenshot of the code area and error screenshot code? Generally wrong codes will be marked with red wavy lines.

In addition,in some areas, peopele use ";" instead of "," and use ";;" instead of ";".Formula separators and chaining operator

If so, you could try this code:

ClearCollect(CityPopulations; {City:"London"; Country:"United
Kingdom"; Population:8615000}; {City:"Berlin";
Country:"Germany"; Population:3562000}; {City:"Madrid";
Country:"Spain"; Population:3165000}; {City:"Rome";
Country:"Italy"; Population:2874000}; {City:"Paris";
Country:"France"; Population:2273000}; {City:"Hamburg";
Country:"Germany"; Population:1760000}; {City:"Barcelona";
Country:"Spain"; Population:1602000}; {City:"Munich";
Country:"Germany"; Population:1494000}; {City:"Milan";
Country:"Italy"; Population:1344000})

Best Regards,

Bof

Thanks for your reply! I just opened the project with the error again, and now it works without the error! I don't think I've made any changes since last time I tried that tutorial section. How strange... Anyway, thank you both for your effort! 😊

View solution in original post

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,355)