web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Hash or checksum for d...
Power Apps
Unanswered

Hash or checksum for data entry

(0) ShareShare
ReportReport
Posted on by 386

I am going to be building an app that will have some data keyed in from another source. In order to minimize or eliminate keying errors, I'd like to have a hash or checksum for each row of data. I can get that done at the source too.

 

So if data looks like this:

Item NumberMonth 1 UnitsMonth 2 UnitsMonth 3 UnitsEntry DateChecksum

 

Doing a checksum on values is easy. How would you suggest I approach getting a checksum to include the item number, which is an alphanumeric string? In VBA I'd just get the length, then loop through it one char at a time and get the ASCII number of the character then do some math with the other numeric values in the row to get a probably unique value that would prevent entry errors.

But Power Apps doesn't support FOR/NEXT loops like that. Other ideas? The item numbers aren't a consistent length so I cannot just parse it out to 10 chars or something and do it that way. It may be between 5 and 12 chars.

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @EdHansberry 

    I feel like it might be easier to answer this question if we had a practical example to work from here.

    • Can you give some sample inputs?
    • What does the checksum process look like?  Give an example with pseudocode or VBA.
    • What is the output?

     

    I have found it possible to create both FOR NEXT and DO WHILE loops in PowerApps so hopefully what I know can be applied to your app.  A good mathematical problem or PowerApps hacking challenge is always fun 🙂

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • EdHansberry Profile Picture
    386 on at
    Item NumberMonth 1 unitsMonth 2 UnitsMonth 3 UnitsDate
    12345AB-R13100020001500Mar-31-2020

     

    I haven't worked out my math yet but for simplicities sake I might do the following

    • Month 1 units * Square Root(Month 2 units) / Month 3 units
    • Take the integer portion of that number and halve it.
    • Add the fractional portion of the date divided by pi
    • Take the first 8 digits of the fraction and convert to an integer ( * 10000000) and add that to the integer portion of that.
    • Convert that numeric string to text, and just use the last 5 digits.

     

    That would give me a simple 5 digit number to key in that would be hard to replicate with wrong data. But I need to work in the item number (alphanmeric) somehow.

     

    Make sense? I'd be happy if I could get the ASCII code of each char of the number and just use the first digit from each and construct another 5-12 digit integer to add to the above before I extracted the last 5 digits.

  • Verified answer
    mdevaney Profile Picture
    29,989 Moderator on at

    @EdHansberry 
    Is the fundamental problem obtaining the ASCII code of each char of the Item Number?

    This is the code I used:

    //Char codes for 0-9 A-Z a-z
    Set(charCodesAlphanumeric,[48,49,50,51,52,53,54,55,56,57,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122]);
    
    //Initialize collections
    ClearCollect(myItemNumber, Split("12345ABR13",""));
    ClearCollect(mySolution, {Char: "", CharCode: 0});
    Clear(mySolution);
    
    //Loop to find Char codes
    ForAll(myItemNumber,
     ForAll(charCodesAlphanumeric,
     If(Char(Value) = Result, Collect(mySolution, {Char: Result, CharCode: Value}))
     )
    )

     

    Resulting in the collection mySolution:

    Capture.PNG

     

    Char code reference here (instead of ASCII):

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-char

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • EdHansberry Profile Picture
    386 on at

    Thanks @mdevaney. That is super helpful. Definitely gives me a path forward.

  • mdevaney Profile Picture
    29,989 Moderator on at

    @EdHansberry 

    You always ask such interesting questions Ed.  This time was no different.  I could not resist!

     

    Now I know who to ask if I need help with making a checksum algorithm.  You seem to be very keen on the subject 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard