cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JScherff
Frequent Visitor

Combobox selected value updates label text

Hello!

 

I have a combobox, "cboResolutionTimeinput" with the following items as selections:

["Already Complete","1 Week","2 Weeks","3 Weeks","1 Month","2 Months","3 Months","4 Months","5 Months","6 Months"]

 

When the user selects the value, I'm trying to update a label lblResolutionDueDate with the corresponding due date.  I'm using the formula:

 

If(cboResolutionTimeinput.Selected.Value = "1 Week", lblResolutionDueDate.Text = DateAdd(Now(), 7), "dd-mm-yyyy"), Blank()) 

 

 Based on the selection, the DateAdd will change to match the selection (with the exception of "already complete" which will just use the current date).

 

After searching for an answer, I've come up empty.  Any assistance would be very appreciated.

 

Thank you,

John

2 ACCEPTED SOLUTIONS

Accepted Solutions
JScherff
Frequent Visitor

Got it!

 

I just needed to modify the formula a bit and put it in the Text option of the label.

 

I used:

If(cboResolutionTimeinput.Selected.Value = "1 Week", DateAdd(Today(), 7), "")

 

I'll need to add in the other If statements to include the rest of the choices, but I think I'm set.

View solution in original post

@JScherff ,

To simplify your process, on combobox items define a table with all informations you need:

 

Table(
    {
        Item: "Already Complete",
        Value: 0,
        Unit: Days
    },
    {
        Item: "1 Week",
        Value: 7,
        Unit: Days
    },
    {
        Item: "2 Weeks",
        Value: 14,
        Unit: Days
    },
    {
        Item: "3 Weeks",
        Value: 21,
        Unit: Days
    },
    {
        Item: "1 Month",
        Value: 1,
        Unit: Months
    },
    {
        Item: "2 Months",
        Value: 2,
        Unit: Months
    },
    {
        Item: "3 Months",
        Value: 3,
        Unit: Months
    },
    {
        Item: "4 Months",
        Value: 4,
        Unit: Months
    },
    {
        Item: "5 Months",
        Value: 5,
        Unit: Months
    },
    {
        Item: "6 Months",
        Value: 6,
        Unit: Months
    }
)

 

There will be no need to check the value of the selected item from combobox.

In your label text property use:

 

Text(DateAdd(Now(),ComboBox.Selected.Value,ComboBox.Selected.Unit),"dd.mm.yyyy")

 

 In this situation, I strongly advice you to change the combobox control with a dropdown. 

 

Hope it helps !

View solution in original post

3 REPLIES 3
JScherff
Frequent Visitor

Got it!

 

I just needed to modify the formula a bit and put it in the Text option of the label.

 

I used:

If(cboResolutionTimeinput.Selected.Value = "1 Week", DateAdd(Today(), 7), "")

 

I'll need to add in the other If statements to include the rest of the choices, but I think I'm set.

@JScherff ,

To simplify your process, on combobox items define a table with all informations you need:

 

Table(
    {
        Item: "Already Complete",
        Value: 0,
        Unit: Days
    },
    {
        Item: "1 Week",
        Value: 7,
        Unit: Days
    },
    {
        Item: "2 Weeks",
        Value: 14,
        Unit: Days
    },
    {
        Item: "3 Weeks",
        Value: 21,
        Unit: Days
    },
    {
        Item: "1 Month",
        Value: 1,
        Unit: Months
    },
    {
        Item: "2 Months",
        Value: 2,
        Unit: Months
    },
    {
        Item: "3 Months",
        Value: 3,
        Unit: Months
    },
    {
        Item: "4 Months",
        Value: 4,
        Unit: Months
    },
    {
        Item: "5 Months",
        Value: 5,
        Unit: Months
    },
    {
        Item: "6 Months",
        Value: 6,
        Unit: Months
    }
)

 

There will be no need to check the value of the selected item from combobox.

In your label text property use:

 

Text(DateAdd(Now(),ComboBox.Selected.Value,ComboBox.Selected.Unit),"dd.mm.yyyy")

 

 In this situation, I strongly advice you to change the combobox control with a dropdown. 

 

Hope it helps !

JScherff
Frequent Visitor

Great suggestion!  Thank you for the information and sample code!

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,238)