cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ramole
Super User
Super User

Dates

Hi All,

 

I wonder if this is possible i have a form and Repeating gallery all i need is when payment frequency dropdown is select monthly the repeating gallery should auto calculate and create 4 lines filled due dates for me at moment i am using this formula and it does creates for me lines :

Could you please try this?

 

1. Set App.OnStart: ClearCollect(ColNum,[1,2,3,4,5,6,7,8,9,10]) 

2. Modify the OnChange of Number Package Textinput box as below, it creates new rows repeatedly based on the values you enter.

 

ForAll(
FirstN(ColNum,Value(DataCardValue60_2.Text)),
Collect( NewShipCollection,
{CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
Clevel: "",
Ctc: "",
Cdescription: ""
}))

 

also screenshot 

 

date set.pngpay.png

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.
1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Ramole :

1\Add a text input control(TextInput1)

2\Then try this code:

ForAll(
    FirstN(
        ColNum,
        Value(DataCardValue60_2.Text)
    ),
    Collect(
        NewShipCollection,
        {
            CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
            'Due Date': Switch(
                Dropdown1.SelectedText.Value,
                "Weekly",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0) * 7,
                    Days
                ),
                "Daily",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Days
                ),
                "Monthly",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Months
                ),
                "Annual",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Years
                )
            ),
            Clevel: "",
            Ctc: "",
            Cdescription: "",
            'loan amount': Value(TextInput1.Text) / Value(DataCardValue60_2.Text)
        }
    )
)

11.gif

Best Regards,

Bof

View solution in original post

8 REPLIES 8
v-bofeng-msft
Community Support
Community Support

Hi @Ramole :

The point is using switch function.

I've made a test for your reference:

1\Add a data picker control(DatePicker1)

2\Add a drop down control(Dropdown1)

Items:

 

["Weekly","Monthly","Daily","Annual"]

 

3\Set the DataCardValue60_2's OnChange porperty to:

 

ForAll(
    FirstN(
        ColNum,
        Value(DataCardValue60_2.Text)
    ),
    Collect(
        NewShipCollection,
        {
            CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
            'Due Date': Switch(
                Dropdown1.SelectedText.Value,
                "Weekly",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0) * 7,
                    Days
                ),
                "Daily",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Days
                ),
                "Monthly",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Months
                ),
                "Annual",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Years
                )
            ),
            Clevel: "",
            Ctc: "",
            Cdescription: ""
        }
    )
)

 

9.gif

Best Regards,

Bof

Hi @v-bofeng-msft 

 

I have tried the code but i get blank on the gallery when i select the dates and payment frequency and number loan dropdown the on change code is on the number of loans dropdown as it collections but the gallery returns blank, here the code which i have modified a bit 

 


ForAll(
FirstN(
ColNum,
Value(DataCardValue45.Selected.Value)
),
Collect(
NewLoansCollection,
{
CItemSerialNumber: Text(Last(NewLoansCollection).CItemSerialNumber + 1),
LoanDueDate: Switch(
DataCardValue8.Selected.Value,
"Weekly",
DateAdd(
DatePicker3.SelectedDate,
Value(Last(NewLoansCollection).CItemSerialNumber + 0) * 7,
Days
),
"Daily",
DateAdd(
DatePicker3.SelectedDate,
Value(Last(NewLoansCollection).CItemSerialNumber + 0),
Days
),
"Monthly",
DateAdd(
DatePicker3.SelectedDate,
Value(Last(NewLoansCollection).CItemSerialNumber + 0),
Months
),
"Annual",
DateAdd(
DatePicker3.SelectedDate,
Value(Last(NewLoansCollection).CItemSerialNumber + 0),
Years
)
),
Clevel: "",
Ctc: "",
Cdescription: ""
}
)
)

 


;Set(HideForm4,true);Set(HideForm3,false)

 

 

wrong.pngblanket.png

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

Hi @Ramole 

please try 

DataCardValue8.SelectedText.Value

instead of 

DataCardValue8.Selected.Value

Best Regards,

Bof

Hi @v-bofeng-msft 

 

Thanks it was ColNum wrong, the correct one was ColNumb, that solved, can the switch handle calculation ? example if the loan amount is $2000 and i select dropdown monthly and numbers of months is 4 can it auto calculate and fill amount field like $500 each month depending how months i select? if yes please help me with formula.

 

Thank you so much.

 

due.png

amount.png

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

Hi @Ramole :

Can you describe your calculation logic in detail? I don’t quite understand. If the total loan is 1,000 and it will be changed in 4 months, why is it 500 per month?

Best Regards,

Bof

Hi @v-bofeng-msft 

 

Sorry i was wrong i mean $2000, i have edited the post.

Thanks 

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

Hi @Ramole :

1\Add a text input control(TextInput1)

2\Then try this code:

ForAll(
    FirstN(
        ColNum,
        Value(DataCardValue60_2.Text)
    ),
    Collect(
        NewShipCollection,
        {
            CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
            'Due Date': Switch(
                Dropdown1.SelectedText.Value,
                "Weekly",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0) * 7,
                    Days
                ),
                "Daily",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Days
                ),
                "Monthly",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Months
                ),
                "Annual",
                DateAdd(
                    DatePicker1.SelectedDate,
                    Value(Last(NewShipCollection).CItemSerialNumber + 0),
                    Years
                )
            ),
            Clevel: "",
            Ctc: "",
            Cdescription: "",
            'loan amount': Value(TextInput1.Text) / Value(DataCardValue60_2.Text)
        }
    )
)

11.gif

Best Regards,

Bof

Thank you so much @v-bofeng-msft 

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,043)