cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tianaranjo
Continued Contributor
Continued Contributor

Numeric - Decimal

Greetings, 

 

I am patching a numeric value to a collection.  In some cases, I will need to add a decimal.  Any advice on how I can modify the below statement to include a decimal if the user selects with the text set to ".".

 

    Patch(
        colKeypadSelectOrder3,
        LookUp(
            colKeypadSelectOrder3,
            Result = fieldSelected
        ),
        {
            Value: 
           
                (LookUp(
                colKeypadSelectOrder3,
                Result = fieldSelected,
                Value
            ) & Value(btnNumKey.Text) * 1)
                }
    )
)
1 ACCEPTED SOLUTION

Accepted Solutions

OK, you are actually working with text and not numbers since you use the & operator.  The values stored in your collection are text.

Hence you should just forget about Value and * 1 then the . will be added.

Something like this:

Patch(
        colKeypadSelectOrder3,
        LookUp(
            colKeypadSelectOrder3,
            Result = fieldSelected
        ),
        {
            Value: 
           
                (LookUp(
                colKeypadSelectOrder3,
                Result = fieldSelected,
                Value
            ) & btnNumKey.Text)
                }
    )
)

However this will not prevent people from adding two or three .'s

 

For this you will need to check if there is a . present and disable the . button for example

View solution in original post

6 REPLIES 6
Meneghino
Community Champion
Community Champion

The Value() function has a second argument to define how to convert text to numbers.

If you set the second parameter to "en-US" for example, any '.' will be seen as a decimal separator.

If the second parameter is set to "it-IT" for example then the decimal separator will be a ','

tianaranjo
Continued Contributor
Continued Contributor

@Meneghino Thank you for the immediate reply! 

 

With that in mind, can you recommend how I modify the patch statement to receive the decimal as input if a user selects the button?  

Difficult to say without knowing more about how your app works.

What is btnNumKey.Text?

Why do you multiply by 1?

tianaranjo
Continued Contributor
Continued Contributor

@Meneghino I am using a numeric keypad for numeric entries in the app.  btnNumKey.text is the value of the button selected and * 1 is used to basically convert the text into a value.  

 

Hope this helps.

 

OK, you are actually working with text and not numbers since you use the & operator.  The values stored in your collection are text.

Hence you should just forget about Value and * 1 then the . will be added.

Something like this:

Patch(
        colKeypadSelectOrder3,
        LookUp(
            colKeypadSelectOrder3,
            Result = fieldSelected
        ),
        {
            Value: 
           
                (LookUp(
                colKeypadSelectOrder3,
                Result = fieldSelected,
                Value
            ) & btnNumKey.Text)
                }
    )
)

However this will not prevent people from adding two or three .'s

 

For this you will need to check if there is a . present and disable the . button for example

tianaranjo
Continued Contributor
Continued Contributor

@Meneghino

 

Thanks!  You've been a great help.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,360)