cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Calculations within PowerApp

Hi,

 

Brand new to PowerApp!!

 

I am looking to create an App for a License Calculator.

 

Essentially I have a number of different License Packs; 10,000 | 5,000 | 1,500 | 500 |100

 

I want the user to enter the Total Number of Licenses Required and then the Calculation would work out how many of each License Pack is required in the background and then Present this to the user.

 

i.e. If the user enters: 17598....It responds with:

 

10,000 = 1

5,000 = 1

1,500 = 1

500 = 2

150 = 1

 

I have created this successfully in Excel - Which I have provided.

 

However when I look to recreate this in PowerApp using Text Inputs and Formulas after the first two calculations the App starts to slow down, if I add all the calculations, the App becomes unresponsive!!!

 

I have also provided a 'working' App which just uses a few calculations and also a 'non-working' App to show how it hangs (NOTE: Please save any other work before opening the 'non-working' version as this will crash the PowerApp application or the Web Browser!!)

 

All files can be found in the following DropBox: https://www.dropbox.com/sh/wc8cam53evnrpke/AABpVV1AWQx1fBiNtdKkwv2Va?dl=0

  

Any help, pointers and advice is greatly appreciated.

 

Thanks.

 

David

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Calculations within PowerApp

Hi @DH

Your issue intrigued me so I had a look.  The answer is to keep it simple.  I am not sure why you use cards.  I never use cards or forms in PowerApps as I think they are currently poorly designed and very very difficult to customise.

 

Here is the solution:

1) Start with a blank app

2) Create a text input

3) Create 5 labels

4) Set the formula for each of the five labels as follows:

RoundDown(Value(TextInput1.Text)/10000,0)

RoundDown((Value(TextInput1.Text)-10000*Value(Label1.Text))/5000,0)

RoundDown((Value(TextInput1.Text)-10000*Value(Label1.Text)-5000*Value(Label2.Text))/1500,0)

RoundDown((Value(TextInput1.Text)-10000*Value(Label1.Text)-5000*Value(Label2.Text)-1500*Value(Label3.Text))/500,0)

Value(TextInput1.Text)-10000*Value(Label1.Text)-5000*Value(Label2.Text)-1500*Value(Label3.Text)-500*Value(Label4.Text)

 

Screenshot below.  Please let me know how you get on.

 

__.JPG

View solution in original post

2 REPLIES 2
Highlighted
Community Champion
Community Champion

Re: Calculations within PowerApp

Hi @DH

Your issue intrigued me so I had a look.  The answer is to keep it simple.  I am not sure why you use cards.  I never use cards or forms in PowerApps as I think they are currently poorly designed and very very difficult to customise.

 

Here is the solution:

1) Start with a blank app

2) Create a text input

3) Create 5 labels

4) Set the formula for each of the five labels as follows:

RoundDown(Value(TextInput1.Text)/10000,0)

RoundDown((Value(TextInput1.Text)-10000*Value(Label1.Text))/5000,0)

RoundDown((Value(TextInput1.Text)-10000*Value(Label1.Text)-5000*Value(Label2.Text))/1500,0)

RoundDown((Value(TextInput1.Text)-10000*Value(Label1.Text)-5000*Value(Label2.Text)-1500*Value(Label3.Text))/500,0)

Value(TextInput1.Text)-10000*Value(Label1.Text)-5000*Value(Label2.Text)-1500*Value(Label3.Text)-500*Value(Label4.Text)

 

Screenshot below.  Please let me know how you get on.

 

__.JPG

View solution in original post

Highlighted
New Member

Re: Calculations within PowerApp

Hi @Meneghino,

 

Thank you for your response, this worked very well!!

 

I started using cards as I would like to list the part number, description and price of the licence pack (which I am using a lookup on a table for) and I can then hide the ones with a "0" value and the other cards align next to each other - I'm still deciding if this is the correct approach, or if I can use a gallery to the same affect.

 

In your fantastic example below it finished with "98" rather than having a "0" or "1" so I copied the formula you used in the other labels to Lable5 for this to show "0" then added an extra label with the formula:

 

If(Mod((Value(TextInput1.Text)-10000*Value(Label1.Text)-5000*Value(Label2.Text)-1500*Value(Label3.Text)-500*Value(Label4.Text))/150,1)=0,0,1)

 

This checks if the value calculated for Label4 was a whole number or not and if not returns a "1" for Label6, which would effectively be adding another 150 Licence Pack. In this example: Label4=2.196(without Rounding Down), Label5=0 (98/150) and Label6=1(as Label4 is not a whole number).

 

I then took this all a step further; rather than using Labels I added each of these into variables via a Button called "Calculate":

 

Set(tt,RoundDown(Value(TextInput1.Text)/10000,0));
Set(ft,RoundDown((Value(TextInput1.Text)-10000*tt)/5000,0));
Set(otfh,RoundDown((Value(TextInput1.Text)-10000*tt-5000*ft)/1500,0));
Set(fh,RoundDown((Value(TextInput1.Text)-10000*tt-5000*ft-1500*otfh)/500,0));
Set(ohf,RoundDown((Value(TextInput1.Text)-10000*tt-5000*ft-1500*otfh-500*fh)/150,0)+If(Mod((Value(TextInput1.Text)-10000*tt-5000*ft-1500*otfh-500*fh)/150,1)=0,0,1))

 

I can now refernce these at any point which makes other calculations easier.

 

Thank you again for your valuable help.

 

David

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,576)