@Vithushan Try creating a new app with existing Power Apps template. Check the logic given in the app which might help you:
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.