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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Reference a Sharepoint...
Power Apps
Answered

Reference a Sharepoint Value as a Variable

(0) ShareShare
ReportReport
Posted on by 46

Good morning friends! I'm building a PTO Power App, and I've created a list that stores records of employee's available PTO seperated by type.  The idea is that the user can select an option from a choice form, and depending on the selection two variables will be updated;  one as a string, and one as the number.  I've created a switch that should handle this, but when an option is selected the value returns as blank.  Earlier in the form, I reference the column value via lookup in a gallery and it works fine, so I'm assuming it's just bad code on my end.  Can anyone help?  For reference, the VacationDaysCurrent/PersonalDaysCurrent are the columns in the list.

 

I've tried referencing the columns as ThisItem.VacationDaysCurrent, VacationDaysCurrent.Value, and just VacationDaysCurrent, and using ThisItem format at least doesn't error out, but returns a blank value.  I currently have it set as a Text label where SelectedTimeOffAvailableDays is the Text, and still no value is being returned.  

 

Switch(
DataCardValue22.Selected.Value,
"Vacation",
Set(SelectedTimeOff, "Vacation");
Set(SelectedTimeOffAvailableDays, ThisItem.VacationDaysCurrent),
"Personal",
Set(SelectedTimeOff, "Personal");
Set(SelectedTimeOffAvailableDays, ThisItem.PersonalDaysCurrent),
"Holiday",
Set(SelectedTimeOff, "Holiday");
Set(SelectedTimeOffAvailableDays, ThisItem.HolidayDaysCurrent),
"Health & Wellness",
Set(SelectedTimeOff, "Health & Wellness");
Set(SelectedTimeOffAvailableDays, ThisItem.HealthAndWellnessDaysCurrent),
"Carry Over",
Set(SelectedTimeOff, "Carry Over");
Set(SelectedTimeOffAvailableDays, ThisItem.CarryOverDaysCurrent),
Set(SelectedTimeOff, "");
Set(SelectedTimeOffAvailableDays, 0)

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @DarkoTheNoob,

     

    We can make a few smaller adjustments, but overall the code looks good te me (just missing a closing bracket at the end). Please make sure that the code below is written in the OnChange of the Dropdown and that the text values match the dropdown text exactly (pay attention to capitalization):

     

    Concurrent(
     Set(SelectedTimeOff, Self.Selected.Value),
     Switch(
     Self.Selected.Value,
     "Vacation",
     Set(SelectedTimeOffAvailableDays, ThisItem.VacationDaysCurrent),
     "Personal",
     Set(SelectedTimeOffAvailableDays, ThisItem.PersonalDaysCurrent),
     "Holiday",
     Set(SelectedTimeOffAvailableDays, ThisItem.HolidayDaysCurrent),
     "Health & Wellness",
     Set(SelectedTimeOffAvailableDays, ThisItem.HealthAndWellnessDaysCurrent),
     "Carry Over",
     Set(SelectedTimeOffAvailableDays, ThisItem.CarryOverDaysCurrent),
     Set(SelectedTimeOffAvailableDays, 0)
    )

    Note that 'ThisItem' in a Form control, refers to the record that is referenced in the Item property. Should you use the Form to create a new row in SP, then ThisItem will be blank since you are still creating the record - in this case you will need a LookUp() to reference the record storing the PTO information.

     

    On the OnVisible of that screen you may want to assign those Variables a default value

    //This also takes care of resetting the variables
    Concurrent(
     Set(SelectedTimeOff, Blank()),
     Set(SelectedTimeOffAvailableDays, 0)
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • DarkoTheNoob Profile Picture
    46 on at

    Hello @LaurensM!

     

    That's great code cleanup, and a good idea on the OnVisible!  I also added the LookUp function to your Switch Code, and it worked perfectly.  Posting full code in case anyone needs a similar solution in the future (I'm sure the LookUp Function could be abbreviated, but this did end up working) -

     

    Concurrent(
         Set(SelectedTimeOff, Self.Selected.Value),
         Switch(
              Self.Selected.Value,
              "Vacation",
              Set(SelectedTimeOffAvailableDays, LookUp('Time Off Balances', Employee.Email=curUserEmail, VacationDaysCurrent)),
              "Personal",
              Set(SelectedTimeOffAvailableDays, LookUp('Time Off Balances', Employee.Email=curUserEmail, PersonalDaysCurrent)),
              "Holiday",
              Set(SelectedTimeOffAvailableDays, LookUp('Time Off Balances', Employee.Email=curUserEmail, HolidayDaysCurrent)),
              "Health & Wellness",
              Set(SelectedTimeOffAvailableDays, LookUp('Time Off Balances', Employee.Email=curUserEmail, HealthAndWellnessDaysCurrent)),
              "Carry Over",
              Set(SelectedTimeOffAvailableDays, LookUp('Time Off Balances', Employee.Email=curUserEmail, CarryOverDaysCurrent)),
              Set(SelectedTimeOffAvailableDays, 0)
    ))

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard