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

Newbie help required

So, I'm trying to teach myself PowerApps from a variety of sources and seem to be failing at the first hurdle and would be appreciative of someones input so I can move on in my PowerApps travels.

I have set up, what should be, a very simple scenario to test the use of Global variables.

Simple screen, when I select "App" on the treeview, I select the "OnStart" property and declare two global variables:-

Set(LabelText,"");
Set(_CurrentWeekNo, RoundDown((RoundUp(Today()-Date(Year(Today()-Weekday(Today()-1)+4),1,3),0)+Weekday(Date(Year(Today()-Weekday(Today()-1)+4),1,3))+5)/7,0))   

 

The second declaration is meant to calculate the week number of the current date, I found the equation online, I'm not too bothered whether it gives the right answer at the moment, I'm simply trying to actually use the variable in a screen.

 

In Screen1 I then have 3 items:-

LabelHello, simple label, only property set is the text property which is set to the variable LabelText

Button1: onselect property set to  Set(LabelText,Text(_CurrentWeekNo,"[$-en-GB]0"))

Button2: onselect property set to  Set(LabelText,"")

 

The idea is when the app is run, the label should start blank then if I click Button1, the label text should display the week number, if I click button2, the text should clear.

 

As I said, should be easy, it's just not working ie button1 doesn't display the current week number.

 

Any help / guidance anyone can provide would be really welcome.


Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User III
Super User III

Hi @davec1 

It's quite possible that your _CurrentWeekNo variable isn't set. This will explain why nothing happens when you click Button1.

To confirm if this is the case, what happens if you were to set the text property of a label to _CurrentWeekNo? Do you see the correct week number? If not, you should run your OnStart formula using the menu item in the context menu.

 

timl_0-1605116516009.png

 

View solution in original post

2 REPLIES 2
timl
Super User III
Super User III

Hi @davec1 

It's quite possible that your _CurrentWeekNo variable isn't set. This will explain why nothing happens when you click Button1.

To confirm if this is the case, what happens if you were to set the text property of a label to _CurrentWeekNo? Do you see the correct week number? If not, you should run your OnStart formula using the menu item in the context menu.

 

timl_0-1605116516009.png

 

View solution in original post

davec1
Frequent Visitor

@timl1, thanks very much for your quick response. I tried running the OnStart formula from the context menu and that works now, thank you.

 

As a newbie, is this just something to look out for when dealing with variables in PowerApps or is there a specific reason it wouldn't work without doing this ?

 

Many thanks again, much appreciated

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

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

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,215)