Showing results for 
Search instead for 
Did you mean: 

Generate Account number dynamically with Math functions in Power Apps

Business scenario:

In my App, I need to generate an account number dynamically also I should ensure that it is not part of the inventory/DB.



Use the Math function Random to generate a number and append that number to a prefix as per the business need. Also, do a lookup on the inventory / DB to ensure that ID is not part of the system before.



Create a text box / a label on the screen and use the below formula to show the Account-ID dynamically.


In the above formula Rand() will give a value in fractions of 12 decimal, but I want to get the value with 6 digit number only. So, I have multiplied the result by 1million. After the multiplication, I don't need the decimal anymore so I have rounded the value to 0. This will give me only the 6 digits numeric value.

Now once I get the number I am appending it to "Acc" (you can change it as per your business needs) to make the account number in mode readable format.


Now that we got the number while adding the entry in the Data source use the below look up and ensure that the number is not duplicated.


If(IsBalnk(Lookup(sharepointlistname, columnname=Textbox.Text)),Patch(SPListName,Record),Notify("Account number duplicate");


Microsoft documentation on Rand function


Hope this helps!


Happy learning in Power Apps.!