cancel
Showing results for
Did you mean:
Level: Powered On

## Help Replicating Excel Forumlas into PowerApps form

Version:1.0 StartHTML:000000239 EndHTML:000003880 StartFragment:000002014 EndFragment:000003848 StartSelection:000002014 EndSelection:000003844 SourceURL:https://powerusers.microsoft.com/t5/forums/postpage/board-id/PowerAppsForum1

Hi I have an excel sheet that contains various formulas to calculate values based around a set of user defined dates.

Im trying to create a PowerApps form that will populate an Sharepoint List with the values the user enters and the calculations it shows from what they entered.

User entered Dates are Date of Birth(DOB), JoinDate, LeaveDate2.

I have managed to already calculate Age at Joining(as an Age) and date will or was 41 (as a date) which populate labels on the form.

Im nowÂ  trying to calculate years of service < 41 and years of service >41Â

In excel this is achieved using the following formula - through 4 formulas.

Calculation 1 - isÂ

=ROUND(IF(F2<C2,"0",IF(F2<A2,(F2-C2)/365.25,(A2-C2)/365.25)),2)

Calculation 2Â  isÂ

=ROUND(IF(F2>A2,"0",IF(F2<C2,(A2-C2)/365.25,(A2-F2)/365.25)),2)

The value from Calculation 1 is then passed to Service <41 using the follwing forumla

=IF(C2=0,0,IF(G4+H4<20,G4,IF(H4=20,"0",IF(H4<20,20-H4,"20"))))

The value from calculation 2 is passed to service >41 using

=IF(H4="0",H4,IF(H4>20,20,H4))

For ease here is a shot of the worksheet in excel Ive tried to replicate the Caluclation formula 1 - to a label control on the Powerapps form setting the text to the following format but it isnt working

Round(If((DateValue(Age41Text.Text)<DateValue(JoinDateText.Text), 0,If((DateValue(Age41Text.Text)<DateValue(LeaveDate2.Text),(DateValue(Age41Text.Text)-DateValue(JoinDateText.Text))/365.25,(DateValue(LeaveDate2.Text)-DateValue(JoinDateText.Text))/365.25)),2)

Any ideas how I can do this? 