cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Julien2
Post Prodigy
Post Prodigy

Concat the new result and separate the numbers by (-)

Hello,

I have a SharePoint List form that I am customizing it using Power Apps form.

In this form, I have 3 fields which are: Additional Days Used, Balance of Annual, and Unpaid Leave Taken.

On Submit, I am storing the result of the calculated values in the list.

What I want to achieve is the following:

On submission of the button and while storing the data, I want to concatenate to the saved result the new number and separate the numbers by (-).

For example:
let's say, for the first time a number is stored inside the unpaid leave taken field, then it will show only 1. Now for the second time let's say there is a new update for this field, so instead of replacing the new number with the old one, I want to concat the new number and add (-) between them. So the result will be 1-4. (Using this way I can keep a reference for the old Unpaid leave taken numbers).

Patch(
    'Employees Information',
    First(
        Filter(
            'Employees Information',
            EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName
        )
    ),
    {'Unpaid leave taken': Label5.Text}
);

 

Please have a look at the screenshots below:

Capture.JPGCapture2.JPG
The above screenshot shows the sick leave requested column result 5-1, I want to implement the same logic for the Unpaid Leave Taken field. (I have achieved this result for the Sick leave requested column in Power Automate, I want to know how it can be done in Power Apps).

In Power Automate:

if(equals(variables('Leave History'),'None'),variables('Leave Days'),concat(variables('Leave History'),'-',variables('Leave Days')))

 

What should be the updated patch function to append the new number and separate them by a (-) instead of replacing each time with the new updated number?

Can please someone explain in detail and provides an example to achieve the above scenario?

Any help will be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Julien2 ,

Please consider modify your formula as below:

Patch(
    'Employees Information',
    LookUp(
            'Employees Information',
             EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName
    ),
    {
       'Unpaid leave taken': If(   // modify formula here
                                !IsBlank(LookUp('Employees Information', EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName, 'Unpaid leave taken')),
                                LookUp('Employees Information', EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName, 'Unpaid leave taken') & "-" & Label5.Text,
                                Label5.Text
                             )
    }
);

 

Please consider take a try with above formula, 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.

View solution in original post

4 REPLIES 4
ZabiBabar
Continued Contributor
Continued Contributor

I hope this helps!

Set(
  Employee, 
  First(
    Filter(
     'Employees Information',
      EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName
    )
  )
);
Patch(
  'Employees Information',
   Employee,
    {
      'Unpaid leave taken': Concatenate(Employee.'Unpaid leave taken', "-", Label5.Text)
    }
);

 

Best,
Zabi
Mark this post as a solution, or kudo it if you found it be helpful. You can choose more than multiple answers as solutions, including your own answer. 🙂

v-xida-msft
Community Support
Community Support

Hi @Julien2 ,

Could you please share a bit more about the "Unpaid Leave Taken" field in your SP List? Is it a Text type column?

 

Based on the needs that you mentioned, I think PowerApps canvas app could achieve your needs. On your side, please consider modify your Patch formula as below:

Patch(
    'Employees Information',
    LookUp(
            'Employees Information',
             EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName
    ),
    {
       'Unpaid leave taken': LookUp('Employees Information', EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName, 'Unpaid leave taken') & "-" & Label5.Text
    }
);

Note: Please make sure the "Unpaid leave taken" field is a Text type column in your SP List rather than Number type, to store such the '5-2' text value. 

or

Patch(
    'Employees Information',
    LookUp(
            'Employees Information',
             EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName
    ),
    {
       'Unpaid leave taken': If(
                                !IsBlank(Label5.Text),
                                LookUp('Employees Information', EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName, 'Unpaid leave taken') & "-" & Label5.Text
                             )
    }
);

 

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.

Hello @v-xida-msft ,

Yes, the "Unpaid Leave Taken" field is a Text type column.

Based on the formula you mentioned it works as expected.

But unfortunately, if the unpaid leave taken was blank and the first time the number is stored it shows "-4-3..." knowing that the first number should be stored without "-" then it should separate them by (-) (4-3..).
Capture.JPG

Any suggestions to solve this issue?

Looking forward to your response.

Thank you!

Hi @Julien2 ,

Please consider modify your formula as below:

Patch(
    'Employees Information',
    LookUp(
            'Employees Information',
             EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName
    ),
    {
       'Unpaid leave taken': If(   // modify formula here
                                !IsBlank(LookUp('Employees Information', EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName, 'Unpaid leave taken')),
                                LookUp('Employees Information', EmployeeName.DisplayName = DataCardValue2.Selected.DisplayName, 'Unpaid leave taken') & "-" & Label5.Text,
                                Label5.Text
                             )
    }
);

 

Please consider take a try with above formula, 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.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,298)