Multi LookUp - Check for unique values - sharepoint

I´m trying to set up unique values in my PowerApp-Form. The data is stored in a Sharepoint list. I have a column called watches, items in this column have a unique number, which have to be unique. People can pick multiple of those watches in a LookUp-field. But before submitting the form, I need to check if those picked values already exist in my list and at least display an error message.
I have setup a regular text field and added following rule to it:
If(LookUp(MyList.Watches;DataCardValue4.SelectedItems.Value in Watches;"OK")<>"OK";"No Error";"Watch already exist")
DataCardValue4 is my LookUp field, where people can pick those watches. With this rule I want to check if a item already is in my column watches and let my text field display the error. Somehow the rule doesn´t work.
Can you tell me how I compare multiple lookup choices to my table/column entries?

The first parameter to the LookUp function should be the table (SharePoint list) rather than the column. So the first parameter should be 'MyList' rather than 'MyList.Watches'. Also, I'm not sure that the formula provided (second parameter to LookUp) will work. In your formula, you will be looking for multiple items (DataCardValue4.SelectedItems.Value) within multiple items (Watches). Perhaps you can update your app to have users only pick one watch value before submitting?
One last thing to note. I'm not sure how big you expect your SharePoint list to get, but I would highly recommend keeping your LookUp formula within the bounds to support delegation. More specifically, SharePoint has different formula requirements than other connectors. For example, you can use '=' in your formula, but not 'in'.
Your new rule might look something like below. Please note that it could have syntax errors and might not even be delegable in it's current form since I am providing the rule with no checking. Also, I switched from using LookUp to using Filter instead just because I'm more familiar with Filter. However, both functions are very similar.
If(CountRows(Filter(MyList; DataCardValue4.Selected.Value = Watches)) > 0; "Watch already exist"; "No Error")

Related

When one field doesn't equal another field then show a completely different field

First time asking a question and have learned a lot from this forum. I work in a weird industry and we are using NetSuite. I am having a hard time coming up with a criteria or formula for what I am trying to do. On any sales order we have the Business Source who could be the listing agent or the selling agent for a property. The business source is not always the listing agent or always the selling agent. So I am trying to do a search where (excuse the bad coding example):
If business source is the listing agent, then show the selling agent
If business source is the selling agent, then show the listing agent
From a sales perspective, we want to reach out to the other agent, even if they didn't direct the order our way, and thank them for working with us.
I hope I was somewhat clear...and thanks in advance!
Add a line in the Results tab and select Formula (text) under the Field column. In the Formula column add:
CASE WHEN {custbody_business_source} = {custbody_listing_agent} THEN {custbody_selling_agent} ELSE {custbody_listing_agent} END
You will need to replace the fields in braces {} with the correct IDs for the fields you're using. I have assumed that these fields all pull from the same list of records (contacts or customers) for the information they contain. It probably won't work, for example, if one is a select (List/Record) field and the others are Free Text. This simply compares the Business Source field with (arbitrarily) the Listing Agent and returns the Selling Agent if there's a match, otherwise it returns the Listing Agent. Note that this means the Listing Agent will be returned in any other circumstances also; for example if one of the compared fields is empty.
You could match the Business Source against both the agent fields explicitly and return some other value when neither match by extending the CASE statement a little:
CASE WHEN {custbody_business_source} = {custbody_listing_agent} THEN {custbody_selling_agent} WHEN {custbody_business_source} = {custbody_selling_agent} THEN {custbody_listing_agent} ELSE {somethingelse} END
or by using a DECODE instead:
DECODE({custbody_business_source}, {custbody_listing_agent}, {custbody_selling_agent}, {custbody_selling_agent}, {custbody_listing_agent}, {somethingelse})
DECODE has the following signature:
DECODE({expr}, search, result, [search, result]..., [default])
It compares expr with each search value one by one. If it finds a match it returns the corresponding result. If no match is found, the default is returned, or null if default is not specified.

Allow exception for dependent (secondary) data validation

I am trying to make a form that will give users a list of possible defects to choose from when reporting a customer complaint. First they will choose from a list of regions on the product where the problem exists and then they will choose from a list of possible defects which will populate based on the location selected in the first list. I have made the list of regions as comprehensive as possible but I feel that it is likely that something will arise where I have not forseen this issue as a possibility. As such I would like to include an "Other" option in the location drop down list which, when selected, would change the second data entry point from a data validation list to allowing the user to typ anything the user would like to add. Is this possible to have the type of data validation dependent on a condition?
Dependent dropdown lists validation. Reference youtube video one and two
You can mention "Others" option on the top of the source list for the first (Location) validation. You can then add data validation for the first list using named range with offset function. This will allow you to freely add other locations at the bottom of the list.
For the second column validation, you can enter formula skipping the first ("Others") cell in the location list.
In the image below, validation source list for column D is $A$2:$A$10 and validation list formula for Column E is =IF(COUNTIF($A$3:$A$10,$D2)>0,$B$2:$B$10,$E2)

Fix the structure of the SSRS Matrix

I have been working on a small project. I am trying to display all the results in the same row without NULL values. I've written a small expression to remove the Null values already "=IIF(IsNothing(Fields!RegisterNo.Value),True,False)". However, the rows seem to be moving one level down as it is displayed in the picture ResultMatrix1. I want the results to be on the same level. Can you please tell me if this is possible and how I can achieve it. Is it something to do with the groupings or something else?
Design Groupings
By default, when you create a table, there is a Row Group called "Details" that is not actually grouped by anything. This causes it to produce one row for each row from the dataset. Since you are trying to group these, you need to make sure that innermost group is grouped by your Staff Ref No.
In the lower-right cell, you may need to change the expression to use a Max function. This will simply avoid arbitrarily showing blanks when they happen to be sorted before a real value within that group.

Saving SharePoint list item as draft without required fields

E.g. there is a list with gazillion required fields and I want the users to be able to fill out whatever they can and save as a draft until they have full info? Is there a simple solution for this? Tia!
Option 1: Multiple Content Types
One approach is to have two different Content Types on your list: one for draft items and one for submitted ones.
Content types on the same list can have different settings for the same columns. This means you can make the fields optional on the "draft" content type while making them required on the "submitted" content type.
The downside is that it may not be intuitive for end users if they're required to manually change the "Content Type" field in order to publish their draft.
Option 2: List Validation Settings
Another approach is to use List Validation settings instead of making fields required.
List validation lets you specify an Excel like formula (from which you can reference column values) which must evaluate to true in order for the validation to succeed. If it evaluates to false, a validation error message is displayed instead (you can specify the text of that message) and the item cannot be saved.
Simplified Scenario: One Field
Suppose you have a field called First Field that you don't necessarily need to be filled out right away, and you also have a choice field called Status Field that's used to indicate whether an item is a draft version or is submitted (displaying either "Draft" or "Submitted").
You can set up a list validation formula that requires First Field to be filled in whenever the Status Field is changed to "Submitted".
The formula would look like this:
=If([Status Field]="Submitted",NOT(ISBLANK([First Field])),TRUE)
In plain English, that formula is saying:
If Status Field is equal to Submitted...
...Then the form is valid only if First Field is not blank.
Otherwise, the form is valid.
More Complex Scenario: Multiple Fields
To make that work for multiple fields, you can join conditions together using the OR() and AND() functions, in the format of OR(condtion1,condition2)
So instead of ISBLANK([First Field]) to check whether a field is blank, you'd have something like OR(ISBLANK([First Field]),ISBLANK([SecondField])) to check whether either of two fields is blank. (Replacing First Field and Second Field with your field titles as appropriate.
The formula would now look like this:
=If([Status Field]="Submitted",NOT( OR(ISBLANK([First Field]),ISBLANK([Second Field]))),TRUE)
Note that you can nest multiple OR() conditions together arbitrarily, in the format of OR(condition1, OR(condition2, OR(condition3, condition4))) (and so on indefinitely).
Offloading Formula Complexity to Calculated Columns
If you run into limits with the formula length, you can offload some of your condition calculations into their own calculated columns, then just refer to those column values from your validation formula.
This can also help keep your formula from looking so complex.
For example, for every field that you want to be required, you can create a calculated column with a formula of =NOT(ISBLANK([Column Name])) and name it something like "{Column Name} Is Valid". Then you can refer to those columns in your validation formula:
=If([Status Field]="Submitted",AND([Field1 Is Valid],AND([Field2 Is Valid],[Field3 Is Valid])),TRUE)

how to autocomplete values based on a list

I created many Lists and they are getting longer. At the moment i am using data validation, so I have big lists and need to select the name i want
They are all listed on my formulas, so i would like to know if there is any way
to start to write the name that i need and excel already shows the
possibilities...
I tried to use this formula but was not successful
=OFFSET(Sheet1!$A$1,0,0,MATCH("*",Sheet1!$A$1:$A$300,-1),1)
For instance i have a list of currencies called "CCY", i would like to write
"US" and excel already shows USD. Is there any way to do that?
=OFFSET(Currency,MATCH(A2&"*",Currency,0)-1,0) 'A2 is where the validation applies, make sure it accepts values not in list
You can enter the value in a second go, will let you select from values after.
I wouldn't use it but
It will let you select any value from the drop-down
You can let it do its job by typing "us", Tab, Shift+Tab, Alt+Down and Tab quite fast.
The formula below won't let you select values after, takes the first match only, handle with care.
=OFFSET(Currency,MATCH(A2&"*",Currency,0)-1,0,1,1) 'fun fact: you can give names to data table columns thus creating expanding lists

Resources