cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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 ','

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?

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

View solution in original post

Continued Contributor
Continued Contributor

@Meneghino

 

Thanks!  You've been a great help.

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

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