cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mezcalbean
Advocate II
Advocate II

Calculated field to be submitted to SharePoint with only 4 values

Hi I have a field that is based on a value or a score which in returns a text - thank you  @zmansuri 

 

I have created a SP field called Risk - and works well

 

The problem is when I display the list from a drop down I get all entries  I only want to display from the choice of 4, Low, intermediate, etc. How would I Link that to SP? Do I create a choice field in SP and match it up that way? 

 

With(
{input: Value(charttxt.Text)},
If(
input >= 1 && input < 4,
"Low",
input >= 4 && input < 9,
"Intermediate",
input >= 9 && input < 15,
"High",
input >= 16,
"Very High",
"NA"
)
)
1 ACCEPTED SOLUTION

Accepted Solutions

@mezcalbean ,

Yes, but what is the name of the field and is it in the code you posted - I will assume not for the moment. Note the below relies on your posted code being correct - the choice field is at the bottom

Patch(
   AllSubmittedData,
   Defaults(AllSubmittedData),
   {
      field_1: 
      If(
         Toggle1_1.Value,
         "Yes",
         "No"
      ),
      field_2: 
      If(
         Toggle1_5.Value,
         "Yes",
         "No"
      ),
      field_3: 
      If(
         Toggle1_4.Value,
         "Yes",
         "No"
      ),
      field_4: Radio2_1.Selected.Value,
      field_5: Radio1_2.Selected.Value,
      field_6: Value(TextInput1_6.Text),
      field_7: Value(TextInput1_7.Text),
      field_8: Value(TextInput1_11.Text),
      field_9: Value(TextInput1_10.Text),
      field_10: Value(TextInput1_9.Text),
      field_11: Value(TextInput1_8.Text),
      field_20: Value(Label1_37 + Label1_40 + Label1_41 + Label1_42 + Label1_43 + Label1_35 + Label1_34 + Label1_33 + Label1_32),
      field_21: Value(Label3_13.Text) * 100,
      field_22: Value(Label3_14.Text),
      field_23: Value(Label3_15.Text) * 100,
      Comorbidities: Radio1_3.Selected.Value,
      field123: Text(txtG_1.Text),
      field_24: Text(txtfirstn.Text),
      field_25: Text(txtlastname.Text),
      field_27: Text(txtDOB.Text),
      PT_IDENTIFIER: Text(txt1_3.Text),
      Number: Text(lblmailnickname.Text),
      status: Toggle2.Value,
      YourChoiceField:
      With(
         {
            wChoice:
            With(
            {input: Value(charttxt.Text)},
            If(
               input >= 1 && input < 4,
               "Low",
               input >= 4 && input < 9,
               "Intermediate",
               input >= 9 && input < 15,
               "High",
               input >= 16,
               "Very High",
               "NA"
            )
         ),
         {Value: wChoice}
      )
   }
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

19 REPLIES 19
WarrenBelz
Super User
Super User

Hi @mezcalbean ,

You would filter the List using that

With(
   {
      wRating:
      With(
         {input: Value(charttxt.Text)},
         If(
            input >= 1 && input < 4,
            "Low",
             input >= 4 && input < 9,
             "Intermediate",
             input >= 9 && input < 15,
             "High",
             input >= 16,
             "Very High",
             "NA"
         )
      )
   },
   Filter(
      SPList,
      Risk = wRating
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

WarrenBelz
Super User
Super User

Hi @mezcalbean ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Apologies @WarrenBelz I did write a reply - must of been discarded and not sent, no I have not got this working.

 

I have one page where I am collecting the data, the field and listing it in SharePoint with no issue. When I try and filter it on another page I get the list of every choice entered not the 4 what I am after. I could either be doing the filter incorrectly or the input is incorrect? I have added a picture for example.

 

Also I was unsure what you meant with what is this doing ?

wRating

 

Regards

 

Hi @mezcalbean ,

You can call that whatever you want - I just use that structure. Can you please post the exact code you have used (in Text), what is is returning and what it is you expect.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

mezcalbean
Advocate II
Advocate II

Hi @WarrenBelz 

 

using 

With(
   {
      wRating:
      With(
         {input: Value(charttxt.Text)},
         If(
            input >= 1 && input < 4,
            "Low",
             input >= 4 && input < 9,
             "Intermediate",
             input >= 9 && input < 15,
             "High",
             input >= 16,
             "Very High",
             "NA"
         )
      )
   },
   Filter(
      SPList,
      Risk = wRating
   )
)

 gives me the result of the different levels - that is inputted into SP . in SP I have a list of then many entries of each level with each record. 

 

On the next page I have drop down linking to that dropdown - I want to be able to choose or filter on 4 records as when I link it which gives me the image attached before (list.png) - does this make sense apologies if not?

 

Regards

Hi @mezcalbean ,

Sorry, I a little confused - you want to filter the list according to the input of a text box and the code is doing this. You posted a graph as an example - how is that relevant ?

mezcalbean
Advocate II
Advocate II

Hi @WarrenBelz 

 

I think what I am asking advice on please is to patch a choice field with this  code

With(
{input: Value(charttxt.Text)},
If(
input >= 1 && input < 4,
"Low",
input >= 4 && input < 9,
"Intermediate",
input >= 9 && input < 15,
"High",
input >= 16,
"Very High",
"NA"
)
)

 Thanks 

Hi @mezcalbean ,

Is this inside an existing Patch (you are only specifying this field and the resulting content required)

With(
   {
      wChoice:
      With(
         {input: Value(charttxt.Text)},
          If(
             input >= 1 && input < 4,
             "Low",
             input >= 4 && input < 9,
             "Intermediate",
             input >= 9 && input < 15,
             "High",
             input >= 16,
             "Very High",
            "NA"
            )
         )
      )
   },
   Patch(
   YourSPList,
    . . . CriteriaHere . . .,
   {
      Field1: . . . . 
      Field2: . . . .
      YourChoiceField: {Value:wChoice}
      Field4: . . . . . 
   }
)
      

You can actually put the top statement inside the Patch, but I think this is cleaner.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

 

mezcalbean
Advocate II
Advocate II

Hi @WarrenBelz apologies its me and thank you for your time.

 

I add this to the field

 

With(
   {
      wChoice:
      With(
         {input: Value(charttxt.Text)},
          If(
             input >= 1 && input < 4,
             "Low",
             input >= 4 && input < 9,
             "Intermediate",
             input >= 9 && input < 15,
             "High",
             input >= 16,
             "Very High",
            "NA"
            )
         )
      )
   },

and in the patch statement

Patch(
   YourSPList,
    . . . CriteriaHere . . .,
   {
      Field1: . . . . 
      Field2: . . . .
      YourChoiceField: {Value:wChoice}
      Field4: . . . . . 
   }
)

 

Sorry I am a bit lost - rereading what i said - I use a patch to submit the text box's but unsure with the choice

 

Thankyou

 

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 (4,599)