cancel
Showing results for
Did you mean:
Community Champion

## Value() Question

Hello,

I have an app that will need to make use of Imperial values for distance measurements.

Example: 1' 3 1/8" (one foot, three and one eighth inches)

• Have a Dropdown Control for users to select 1/16" increments
• Each value is set to text (surrounded by " ")
• Need to perform math on the values
• Interestingly, if I use 7/8 instead of "7/8", PowerApps converts to decimal
• However, I am not able to access the fraction with Value("7/8") nor Value(fractionDropdown.Selected.Value)

How can I give the user the ability to select text fractions ("7/8", etc.) but perform math on their selection?

Ideally, I'd like to take things like "1/2" - "1/4" = "1/4" (NOT .25)

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Champion

Wow. Just figured this one out. Hopefully useful to others.

```ClearCollect(colFracConvert,
{imperial: "0", metric:0},
{imperial: "1/16", metric:1/16},
{imperial: "1/8", metric:1/8},
{imperial: "3/16", metric:3/16},
{imperial: "1/4", metric:1/4},
{imperial: "5/16", metric:5/16},
{imperial: "3/8", metric:3/8},
{imperial: "7/16", metric:7/16},
{imperial: "1/2", metric:1/2},
{imperial: "9/16", metric:9/16},
{imperial: "5/8", metric:5/8},
{imperial: "11/16", metric:11/16},
{imperial: "3/4", metric:3/4},
{imperial: "13/16", metric:13/16},
{imperial: "7/8", metric:7/8},
{imperial: "15/16", metric:15/16}
);```

Set Dropdown Control Items Property to:

• Two Dropdown Controls; Measurement 1 and Measurement 2.
• Set both to:
`colFracConvert.imperial`

Insert a (hidden) helper Textbox Control with Text Property set to:

```LookUp(colFracConvert,
measurement1.Selected.Value = imperial, metric
) -
LookUp(colFracConvert,
measurement2.Selected.Value = imperial, metric
)```

Special sauce:

Set the "Difference" Textbox Control Text Property to:

```If(
Value(hiddenHelper.Text) < 0,
"-" &
LookUp(colFracConvert,
Value(
Last(
Split(hiddenHelper.Text,"-").Result
).Result) = metric, imperial
),
"+" & //You could leave this line out if the "+" doesn't matter to your use case
LookUp(colFracConvert,
Value(hiddenHelper.Text) = metric, imperial
)
)```

Whew! Been chewing on that one for a couple days. First time really using text wranglers like Last(Split()).

Enjoy!

Community Champion

Wow. Just figured this one out. Hopefully useful to others.

```ClearCollect(colFracConvert,
{imperial: "0", metric:0},
{imperial: "1/16", metric:1/16},
{imperial: "1/8", metric:1/8},
{imperial: "3/16", metric:3/16},
{imperial: "1/4", metric:1/4},
{imperial: "5/16", metric:5/16},
{imperial: "3/8", metric:3/8},
{imperial: "7/16", metric:7/16},
{imperial: "1/2", metric:1/2},
{imperial: "9/16", metric:9/16},
{imperial: "5/8", metric:5/8},
{imperial: "11/16", metric:11/16},
{imperial: "3/4", metric:3/4},
{imperial: "13/16", metric:13/16},
{imperial: "7/8", metric:7/8},
{imperial: "15/16", metric:15/16}
);```

Set Dropdown Control Items Property to:

• Two Dropdown Controls; Measurement 1 and Measurement 2.
• Set both to:
`colFracConvert.imperial`

Insert a (hidden) helper Textbox Control with Text Property set to:

```LookUp(colFracConvert,
measurement1.Selected.Value = imperial, metric
) -
LookUp(colFracConvert,
measurement2.Selected.Value = imperial, metric
)```

Special sauce:

Set the "Difference" Textbox Control Text Property to:

```If(
Value(hiddenHelper.Text) < 0,
"-" &
LookUp(colFracConvert,
Value(
Last(
Split(hiddenHelper.Text,"-").Result
).Result) = metric, imperial
),
"+" & //You could leave this line out if the "+" doesn't matter to your use case
LookUp(colFracConvert,
Value(hiddenHelper.Text) = metric, imperial
)
)```

Whew! Been chewing on that one for a couple days. First time really using text wranglers like Last(Split()).

Enjoy!

Announcements

#### Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Our team will be reviewing posts using the new "Copilot" label to ensure we highlight and amplify the most relevant and recent content, so you're assured of high-quality content every time you visit. If you share a post that gets featured in the curated gallery, you'll get a PM in the Community to let you know!The curated gallery is ready for you to experience now, so visit the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community. We can't wait to see what you "cook" up!