cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thunter
Level 8

Re: Incremental Values depending on Dropdown

So just a little info.. this app is for our company to report incidents that happen, mostly for our truck drivers but also will be used for inner office performance, etc.

 

Right now there are 1,578 total records. There are 5 Types: "ACC" has 437, "CMP" has 96 , "DOT" has 131, "INC" has 772 and "PER" has 142. As you see from my screenshot below, the way the records are currently stored in SQL. I want to be able to do the same thing with the incident number in PowerApps:

TimRohr
Level 10

Re: Incremental Values depending on Dropdown

So you have the count already there in your record source... your "num" field. That means you can modify @Drrickryp's solution to be a filtered set of returns based on the type:

 

First(Sort(Filter(datasource,type="CMP"),num,descending)).num+1

 

...should get you the next CMP ticket number. A word of warning: this introduces problems of multiple, simultaneous access to the records that you might want to think about if you have a lot of people who will be using this app. You might need a "check out" mechanic to avoid data collisions.

thunter
Level 8

Re: Incremental Values depending on Dropdown

@TimRohr

@Drrickryp

Chances of users using this App at the same time are slim to none, so I dont think I need to worry about that but that is good information to know for future and future apps I build, thank you.

 

So will I need to use this formula with each "Type" when the form is submitted?

TimRohr
Level 10

Re: Incremental Values depending on Dropdown

Yes, but the example was just a proof of concept. Bulletproofing that would involve replacing the direct reference to the type ("INC" or "PER", etc.) with a reference to the control where your user has selected the type. Then you just have one formula that returns the correct number based on how the user classified the new incident they are preparing to track.

 

Make sense?

thunter
Level 8

Re: Incremental Values depending on Dropdown

@TimRohr  @Drrickryp @alsabea

 

Here is what I have when the Submit button is clicked on and the Form is submitted

thunter
Level 8

Re: Incremental Values depending on Dropdown

@TimRohr @Drrickryp @alsabea


So the Default property on my Incident Number DataCard is this:

TypeValue.Selected.Value & "-" RptYearValue.Text & "-" Last('[dbo].[wynne_incidents]').ID +1

 

So does this look correct? And do I need to make a forumla for each Type?

First(Sort(Filter('[dbo].[wynne_incidents]',type="CMP"),num,descending)).num+1

TimRohr
Level 10

Re: Incremental Values depending on Dropdown

If I understand... you have to combine those 2 things... Your constructed value would be:

TypeValue.Selected.Value & "-" RptYearValue.Text & "-" & First(Sort(Filter('[dbo].[wynne_incidents]',type="CMP"),num,descending)).num+1

Except that still explicitly references "CMP". You don't want to do that. You want to reference the control where the user has designated what sort of incident/thing this is. Based on your previous screenshot, I'm going to guess (just a guess) that it might be your "Report Group" dropdown. In that case, you would change the formula to be:

TypeValue.Selected.Value & "-" RptYearValue.Text & "-" & First(Sort(Filter('[dbo].[wynne_incidents]',type=RptGrpDropDown.Selected.Value),num,descending)).num+1

 

thunter
Level 8

Re: Incremental Values depending on Dropdown

@TimRohr @Drrickryp @alsabea

 

The TypeValue which is a dropdown control is where the user selects the Type (ACC, DOT, INC, etc.) 

So maybe something like this:

TypeValue.Selected.Value & "-" RptYearValue.Text & "-" & First(Sort(Filter('[dbo].[wynne_incidents]',type=TypeValue.Selected.Value),num,descending)).num+1

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 278 members 3,428 guests
Please welcome our newest community members: