cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ramole
Resident Rockstar
Resident Rockstar

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 please consider Accept it as the solution to help the others and consider giving it a "Thumbs Up."
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 please consider Accept it as the solution to help the others and consider giving it a "Thumbs Up."

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 please consider Accept it as the solution to help the others and consider giving it a "Thumbs Up."

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 please consider Accept it as the solution to help the others and consider giving it a "Thumbs Up."

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

Thank you so much @v-bofeng-msft 

Thank you
If this post helps, then please consider Accept it as the solution to help the others and consider giving it a "Thumbs Up."

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,414)