cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
colbyturybury
Helper V
Helper V

Filter a collection for a single result

I have a collection that has two columns. One column is called CompressiveStrength and the other is called Strain. There is a formula that returns one of the numbers in Compressive Strength and I need the Strain value to appear in a label. Below is an image. Basically search for a number in the left column and return the value n the right column.  I tried both of these formulas and neither work.

 

Search(colUnconfinedStrength, lblUnconfinedStrength.Text, "Strain")

 

Filter(colUnconfinedStrength, Strain = lblUnconfinedStrength.Text)

 

colbyturybury_0-1627060610630.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Very close. You got me on the right path though! I had to reverse what column you were looking into and make sure the value in the text box was a number.

 

LookUp(colUnconfinedStrength, CompressiveStress = Value(lblUnconfinedStrength.Text),Strain)

View solution in original post

8 REPLIES 8
BCLS776
Super User
Super User

Try a Lookup() instead:

 

Lookup(colUnconfinedStrength, Strain = lblUnconfinedStrength.Text, CompressiveStrength)

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Very close. You got me on the right path though! I had to reverse what column you were looking into and make sure the value in the text box was a number.

 

LookUp(colUnconfinedStrength, CompressiveStress = Value(lblUnconfinedStrength.Text),Strain)

colbyturybury
Helper V
Helper V

So this was working and for some reason I now receive a blank value.

 

LookUp(colUnconfinedStrength, CompressiveStress = Value(lblUnconfinedStrength.Text),Strain)

The CompressiveStress lookup column in your collection has values shown to 7 decimal places of precision, and a rounding difference could make an expression with '=' not work properly. Is there a better way to set this up?

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
colbyturybury
Helper V
Helper V

What if I rounded the data before it entered the CompressiveStress column in the collection?

 


@colbyturybury wrote:

What if I rounded the data before it entered the CompressiveStress column in the collection?

 


That could help, but what I was getting at was that the expression itself could be re-worked to ensure it captures values that are "nearly right". For example,

LookUp(colUnconfinedStrength, 
    CompressiveStress > (Value(lblUnconfinedStrength.Text)-1) &&
    CompressiveStress < (Value(lblUnconfinedStrength.Text)+1) ,
    Strain
)

This expression would return values of Strain that correspond to a +/- 1 unit interval around the given CompressiveStress. I'm not sure if this is an acceptable way to handle the calculation in your app, but it is an option.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

A simple pasting of your formula did work. I will need to verify this through a number of tests. Does power apps struggle with high number of decimal point values?

 

Power Apps doesn't necessarily struggle with decimal places but like any digital representation of numbers, things can get a bit weird at the limits and equivalence is a fleeting concept (e.g. 3.14159265 <> 3.1415927 even if you show it to 6 decimal places). Check out this doc for some more info.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (3,439)