cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Using If function to check previous answer and provide a date depending on the answer

Hello,

 

I'm quite new to PowerApps and a little stuck so looking for some assistance.

 

We have an app where someone is asked to select a Risk Rating. After they submit the form, I'd like the Due Date for the risk to be displayed on the final screen. High = 30 days, Medium = 60 days and Low = 90 Days, so it's a calculated value from the date the form is submitted but depends on what Risk Rating they selected.

 

The following is what I currently use Text( DateAdd( Today(), 30 ), "[$-en-GB]dd/mm/yyyy" ) however this just displays 30 days in the future, I have another for 60 & 90 days (see attached). I need to combine these so it only shows the due date depending on the Risk Rating they select.

 

Is this something anyone can help with, if it's even possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Using If function to check previous answer and provide a date depending on the answer

Hi @Doddy83 ,

Do you want to display  Due Date for the risk based on the Risk Rating they selected after they submit the form?

Firstly, please notice that the data in the form will be invalid after you submit the form.

So you need to save it as variable before you submit the form.

 

Is DataCardValue2 a combo box?

Could you tell me

1)what your data source is?

2)the data type of Risk Rating field?

3)the DataCardValue2's Items?

 

I assume that

1)DataCardValue2 is a combo box

2)your data source is sharepoint list

3)Risk Rating is a choice field

 

If so, I've made a similar test for your reference:

1)set  DataCardValue2's Items :

Choices(datasource.'Risk Rating')

 2)set the submit button's OnSelect:

Set(Risk_Rating,DataCardValue2.Selected.Value);SubmitForm(Form1)

 3)set the label's Text in final screen:

Text(
Swith(Risk_Rating,
"High",
DateAdd( Today(),30,Days),
"Medium",
DateAdd( Today(),60,Days),
"Low",
DateAdd( Today(),90,Days)
      ),
"[$-en-GB]dd/mm/yyyy")

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
Highlighted
Advocate IV
Advocate IV

Re: Using If function to check previous answer and provide a date depending on the answer

You can replace the hard coded '30' with an expression that contains an IF or with a SWITCH. For example (use your own variable/entity names): Switch( chosenRiskRating, RiskRating.High, 30, RiskRating.Medium, 60, RiskRating.Low, 90 ).

Highlighted
Helper II
Helper II

Re: Using If function to check previous answer and provide a date depending on the answer

Thank you so much for the quick reply MrNappa,

 

However I may need a little more hand holding here as I'm still having problems with the formula

 

I've attached a screenshot of the Risk Rating data card which I'm hoping will allow you to provide a formula using the entity names I have used in the app.

 

Should it now look something like this? Obviously it's not right as I'm still getting an error.

 

Text( DateAdd( Today(), Switch( chosenDataCardValue2, DataCardValue2.High, 30, DataCardValue2.Medium, 60, Risk DatacardValue2.Low, 90 ) ), "[$-en-GB]dd/mm/yyyy" )

Highlighted
Advocate IV
Advocate IV

Re: Using If function to check previous answer and provide a date depending on the answer

That seems to contain a syntax error (there's 'Risk' before datacardvalue2.Low).

Highlighted
Community Support
Community Support

Re: Using If function to check previous answer and provide a date depending on the answer

Hi @Doddy83 ,

Do you want to display  Due Date for the risk based on the Risk Rating they selected after they submit the form?

Firstly, please notice that the data in the form will be invalid after you submit the form.

So you need to save it as variable before you submit the form.

 

Is DataCardValue2 a combo box?

Could you tell me

1)what your data source is?

2)the data type of Risk Rating field?

3)the DataCardValue2's Items?

 

I assume that

1)DataCardValue2 is a combo box

2)your data source is sharepoint list

3)Risk Rating is a choice field

 

If so, I've made a similar test for your reference:

1)set  DataCardValue2's Items :

Choices(datasource.'Risk Rating')

 2)set the submit button's OnSelect:

Set(Risk_Rating,DataCardValue2.Selected.Value);SubmitForm(Form1)

 3)set the label's Text in final screen:

Text(
Swith(Risk_Rating,
"High",
DateAdd( Today(),30,Days),
"Medium",
DateAdd( Today(),60,Days),
"Low",
DateAdd( Today(),90,Days)
      ),
"[$-en-GB]dd/mm/yyyy")

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Helper II
Helper II

Re: Using If function to check previous answer and provide a date depending on the answer

Hi @v-yutliu-msft 

 

I've been placed on another project for the time being but I will be retuirning to this over the weekend/early next week so I will be trying it then. I can confirm you assumed correctly and what you have provided looks good but I will confirm it works as soon as I can. Many thnaks for taking the time to reply, its much appreciated.

Highlighted
Community Support
Community Support

Re: Using If function to check previous answer and provide a date depending on the answer

Hi @Doddy83 ,

OK.

You're welcome to post your idea here if your problem still has not been solved.

I will wait for your feedback.

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper II
Helper II

Re: Using If function to check previous answer and provide a date depending on the answer

Hello again @v-yutliu-msft 

Sorry its' taken so long, I've had to re-create the form from scratch as they now want it on a canvas so it's larger. Hence had to build it from scratch, so all the DC's have different names etc.

I'm still having problems with this, I know it's my lack of understanding here thats causing the problems and I'm sure if feel like you're banging your head against a brick wall!

 

This was a nice to have, just to display the calculated Close Out Date of the Corrective Action that has been raised. I've got a calculated column on the list that I've managed to get to work which displays the required caculated date depending on the risk rating thye select so they will just have to go there to check it. The idea here was to have it displayed on the Success Screen when they submit the form just for their quick reference.

 

If your still willing to assist, I've attached screenshots of the Risk Rating DC and Success Screen so you can see what they have been named too. I've also included the Risk Rating choice question and the success screen with the formula.

 

Many thanks for your time so far

Highlighted
Helper II
Helper II

Re: Using If function to check previous answer and provide a date depending on the answer

Just noticed that the screenshot doesnt contain the Swith in the formula, I've tested it with Swith and Switch (presume Swith was a typo in your post?)

Highlighted
Helper II
Helper II

Re: Using If function to check previous answer and provide a date depending on the answer

@mdevaney  - Not sure if you can also help with this one or not? This is more a nice to have so not important to resolve, however I would like to know how it should work if possible.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,990)