cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ud1984
Level: Power Up

Auto Populate Dropdown Menu based on Date calculations

Hi, 

I am very new to PowerApps so apologies if this questions seems daft. 

 

I have 2 dates  Planned Date :  Completion Date : Previously I had a dropdown list for the user to selected the RAG (Red, Amber Green) Status.

 

But now depending upon the following formula the RAG status should change automatically and a record of the RAG status should be stored in the Sharepoint List.

 

The formula is 

Completion Date >Planned Date = Red

Completion Date >80% of Planned Date = Amber

Completion Date <=80% of Planned Date = Green.

 

HELP !!

4 REPLIES 4
shailendra74
Level 10

Re: Auto Populate Dropdown Menu based on Date calculations

Hi @ud1984 

 

How are you displaying your records. In gallery?

 

Thanks.

ud1984
Level: Power Up

Re: Auto Populate Dropdown Menu based on Date calculations

@shailendra74 At the moment the RAG status is displayed in two place

 

Location 1 : As a dropdown selection (edit) on Page 1 for an individual Project

 

The value from this selection is saved in a Sharepoint Master List.

 

Location 2: As a View in Page 2 (Summary Page) for an individual Project

 

The value displayed is retrived from the Sharepoint Master List.


@shailendra74 wrote:

Hi @ud1984 

 

How are you displaying your records. In gallery?

 

Thanks.


 

Highlighted
Lewis
Level: Powered On

Re: Auto Populate Dropdown Menu based on Date calculations

Hi,

Try using an If() statements...

If( Condition, ThenResult [, DefaultResult ] )

For example, the Condition you will be looking for is 'Completion Date >Planned Date' 

ThenResult would be the colour you want displayed or value you would like to change.

If(Value(CompletionDate.SelectedDate) > Value(PlannedDate.SelectedDate), Red)

The above code would be put in the colour property value you would like to change.

For the 80% value, I would recommend finding this value then apply it to the If() statement







Community Support Team
Community Support Team

Re: Auto Populate Dropdown Menu based on Date calculations

Hi @ud1984 ,

Could you please share a bit more about the ">80% of Planned Date"?

Could you please share a bit more about the RAG Status field in your SP List? Is it a Choice type column?

Further, do you want to set a Default value within the RAG Status field in your Edit form based on the Planned Date and Completion Date?

 

Based on the needs that you mentioned, I think the If function could achieve your needs. I assume that the RAG Status field is a Choice type column in your SP List.

 

I have made a test on my side, please take a try with the following workaround:4.JPG

Within the Edit form, unlock the RAG Status Data card, then set the DefaultSelectedItems property of the ComboBox within the RAG Status data card to following:

If(
    EditForm1.Mode = FormMode.New,
    If(
        DataCardValue9.SelectedDate > DateAdd(Date(Year(Today()),1,1), Round(DateDiff(Date(Year(Today()),1,1), DataCardValue8.SelectedDate)*0.8, 0)),
        {
            Value: "Amber"
        },
        DataCardValue9.SelectedDate <= DateAdd(Date(Year(Today()),1,1), Round(DateDiff(Date(Year(Today()),1,1), DataCardValue8.SelectedDate)*0.8, 0)),
        {
            Value: "Green"
        },
        DataCardValue9.SelectedDate > DataCardValue8.SelectedDate,
        {
            Value: "Red"
        }
    ),
    Parent.Default
)

Note: The DataCardValue8 represents the Planned DatePicker control, the DataCardValue9 represents the Completion DatePicker control within my Edit form.

On your side, you should type following formula within the DefaultSelectedItems property of the ComboBox within the RAG Status data card:

If(
    EditForm1.Mode = FormMode.New,
    If(                                 
        CompletionDatePicker.SelectedDate > DateAdd(Date(Year(Today()),1,1), Round(DateDiff(Date(Year(Today()),1,1),  PlannedDatePicker.SelectedDate)*0.8, 0)),   /* <-- Completion Date > 80% of Planned Date */
        {
            Value: "Amber"
        },
        CompletionDatePicker.SelectedDate <= DateAdd(Date(Year(Today()),1,1), Round(DateDiff(Date(Year(Today()),1,1), PlannedDatePicker.SelectedDate)*0.8, 0)),   /* <-- Completion Date <= 80% of Planned Date */
        {
            Value: "Green"
        },
        CompletionDatePicker.SelectedDate > PlannedDatePicker.SelectedDate,     /* <-- Completion Date > Planned Date */
        {
            Value: "Red"
        }
    ),
    Parent.Default
)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

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

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 275 members 4,397 guests
Please welcome our newest community members: