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

View solution in original post

tianaranjo
Continued Contributor
Continued Contributor

@Meneghino

 

Thanks!  You've been a great help.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,578)