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 Platform Community / Forums / Power Apps / Getting slider value i...
Power Apps
Answered

Getting slider value into form/variable

(0) ShareShare
ReportReport
Posted on by 2 Moderator

I have a slider that has three settings: 0 1 2
and want to write some text into a Sharepoint list depending on the value.

Now, I put a textbox in the powerapp with 'Slider_BVJ/k_neu' in the text field.
The readout is correct, I can change on the fly from 0 to 1 to 2

 

Now, if I try to do a logical test in a text box like

 

'Slider_BVJ/k_neu' = 2

 

 it gives back an error instead of true or false which I would have suspected.

 

I think that is why my if functions don't work.

 

Ultimately, I want a certain text
"Ja, problemlos" if the value is 0

"Ja, mit Problemen" if the value is 1

"Nein, auf keinen Fall" if the value is 2

in a form that will update my sharepoint list when I click a button.

 

First, I'm wondering why the slider value is not working as expected.

 

Second, I'm wondering what's the proper way to do this

 

I see 2 ways

1. In the slider write the following lines in "On change"

 

Set (varaufnahmebvjsneuzahl; 'Slider_BVJ/s_neu');;
Set (varaufnahmebvjneu; if ('Slider_BVJ/s_neu' = 0; "Ja, problemlos"; 'Slider_BVJ/s_neu' = 1; "Ja, mit Problemen"; "Nein, auf keinen Fall");;

 

 

2. In the DataCardValue on the form in "Default"

 

 

If('Slider_BVJ/s_neu' = 0 ; "Ja, problemlos" ; 'Slider_BVJ/s_neu' = 1 ; "Ja, mit Problemen" ; "Nein, auf keinen Fall")

 

 

However, neither works.

Any ideas?

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

    @schwibach 

    Skip the variables for all of this!

    I am assuming that the Slider is IN your form in the DataCard for a record field.

    Your Default for the DataCard should be ThisItem.yourDataColumn

    The Default on your Slider should be:

    Switch(Parent.Default;
     "Ja, problemlos"; 0;
     "Ja, mit Problemen"; 1;
     "Nein, auf keinen Fall"; 2
    )

    The Update property of your DataCard should be:

    Switch(yourSliderControlName.Value;
     0; "Ja, problemlos";
     1; "Ja, mit Problemen";
     2; "Nein, auf keinen Fall"
    )

     

    Again, all of this is predicated on your Slider being in the form itself and not outside of it.

     

    I hope this is helpful for you. 

  • schwibach Profile Picture
    2 Moderator on at

    Thanks... Unfortunately, the slider is outside of it.

    I wanted the design to be independent of.

    I could redesign that part of the app to be a form.

    The reason I didn't choose to go with a form is that the users are supposed to report numbers and I wanted to make it more comfortable to change the numbers with buttons and choose from the 3 states with a slider.

    schwibach_0-1610818885922.png

    The upper part shows what was last reported. And the lower part gives you the option to report new values.

  • schwibach Profile Picture
    2 Moderator on at

    Hey Randy, your response tipped me off though!

    I looked at what you're doing and think I figured out how to make it work outside the form, too.
    I added . Value to my code and now it's working (in a textbox)

    If ('Slider_BVJ/s_neu'.Value = 0; "Ja, problemlos"; 'Slider_BVJ/s_neu'.Value = 1; "Ja, mit Problemen"; "Nein, auf keinen Fall")

    I'll test it in the form, too.  

     

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

    @schwibach 

    Yes, you do need to first use the .Value property of the slider to get its value.  You can't just use the control name.

    To make your formula a little easier to read, consider this:

    Switch('Slider_BVJ/s_neu'.Value; 
     0; "Ja, problemlos"; 
     1; "Ja, mit Problemen"; 
     2; "Nein, auf keinen Fall"
    )

     

    SO...this will all be fine.  The approach I took in the response was to address editing a record.  As you have it now, if you were to edit an existing record, your slider will not reflect the value stored in the record being edited - perhaps that's not even a concern in your app, but I wanted to at least provide that solution as well.

     

     

  • schwibach Profile Picture
    2 Moderator on at

    Thanks for teaching me the Switch function. Already implemented it in two other places.

    My form is somehow not submitting.
    The troubleshooting never ends 😉 

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

    @schwibach 

    So, that formula should be on the Update property of your datacard in your form.  That will submit the proper text assuming that the underlying column/field is a Text column.

     

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 739 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 268

Last 30 days Overall leaderboard