cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
goel_gagandeep
Resolver I
Resolver I

How I can split my record into sub entries as per my requirement.

 

goel_gagandeep_0-1661143247890.png

 

As you seen above mentioned picture i.e. the table(LeaveHistory) record's Pic ,
In record pic I have applied for the leave 1/8/2022(from_date)(Session1)-3/8/2022(to_date)(session2) Basically I just want to break this record into three entries for example:
01-08-->01-08=1 day (Full day leave) S1-S2
02-08-->02-08=2 days (full day leave)S1-S2
03-08-->03-08=0.5 day (half day leave)S1-S1 
Here, S1= Session1& S2= Session2
I hope you all now understand my problem, so is there any way to split the record as per the requirement.
Thanks.

3 REPLIES 3
Gochix
Solution Sage
Solution Sage

Hi @goel_gagandeep ,

 

Just to clarify if I understood this right.

 

1) You want to check all records in your Table - LeaveHistory.

2) Split the record - for example if date FromDate 01.08 ToDate 02.08 , also split the days so if NumOfDays - 2 then there will be 2 records now : 01.08 as NumofDays - 1 and 02.08 NumofDays - 1?


_____________________________________________________________________________________
Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

Yes @Gochix , I want the same as per your understanding, so do you have any solution for this?

Here is a quick code before work.
You would need to adjust the logic to calculate dates for old and new record.

A logic to calculate NumOfDays based on the record.

 

But it's a start for you to finish the code for your own needs.

 

 

ClearCollect(NewSessionRecords,YourData);

ForAll(NewSessionRecords As aRecord,
    With({aLookup: LookUp(YourData, Id = aRecord.Id)},
        If(DateDiff(aLookup.FromDate,aLookup.ToDate),
            Patch(YourData, Defaults(YourData),
            {
                EmployeeId: aRecord.EmployeeId,
                FromDate: aRecord.FromDate+1,
                ToDate: aRecord.ToDate-1,
                NumOfDays:1
            }
            );
            Update(YourData,aLookup,
            {
                EmployeeId:aRecord.EmployeeId,
                FromDate:aRecord.FromDate,
                ToDate:aRecord.ToDate-1,
                NumOfDays:aRecord.NumOfDays-1
            })
        )
    )
);

 


_____________________________________________________________________________________
Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,237)