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

Getting slider value into form/variable

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@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.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

6 REPLIES 6
Super User III
Super User III

@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. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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.

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.  

 

Super User III
Super User III

@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.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Resolver I
Resolver I

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

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

Super User III
Super User III

@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.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (70,511)