Joining 2 SharePoints list in Power Automate - sharepoint-online

I am wondering if anyone has a solution for this issue that I am facing. I have finished building a repeating table solution involving 2 SharePoint lists.
List A - This is the main list where the form is hosted to do all the data entry.
List B - This is the list that handles repeating data. It has a column named Base_ID that contain the matching ID from List A (there could be 10 items in List B that goes with 1 item in List A).
What I am looking to do is, create a flow that will get all the data from both lists and do (what you would do in MySQL) is a left join.
Now I did find https://powerusers.microsoft.com/t5/Using-Flows/Merging-two-datasets-in-Power-Automate/td-p/944323 and https://powerusers.microsoft.com/t5/Building-Flows/Join-Two-Datasets-in-Flow/td-p/354458 and I have seen comments regarding performance.
Does anyone here know if there is a faster way to do all of this?

You may want to explain the need to have the data all in one list.
This looks like a parent/child relationship, with multiple records in list B relating to one item in list A. I would just leave this alone.
If you want to build forms with this data, that is no problem with PowerApps. You can build screens that show the parent item and a table of all related items by filtering list B with the ID from the List A item. You can add/remove/edit items from List B in PowerApps easily.
If you want to run reports on the data with Excel and Power BI, pull the two list as separate queries and do a merge (i.e. join) in the Query editor.
That way you can keep the data normalized and avoid duplication of values.
Edit after comment: To join the data from the two lists, so you can compose an email notification, you can use the following approach:
Use Get Items from list A that require processing
for each item in the list (Outer loop)
Get items from list B where the ID matches the A item ID
for each item returned from list B (inner loop)
write item details into a collection
next item from list B (end inner loop)
send notification with item details
next item from list A (end outer loop)
This kind of processing is not hard to do and unless you have thousands of records it will not take too long to process.

Related

Create Notes view for duplicate parent documents

We have an Xpages application and recently discovered an issue where there are several Notes documents that have duplicates but the duplicates are PARENT documents too and NOT response documents. Is it possible to create a Notes view that will show duplicates where all the duplicates are parents? I know the formula for showing conflicts is the following but what about where they are all parents?
SELECT #IsAvailable($Conflict)
Expounding on my comment:
Create a view which is categorized on the first column
In the first column formula, put in criteria that you would use to determine a duplicate. This may be the Document Unique ID, or maybe another field or combination of fields.
Add a second column that contains the number 1. Then enable column totals on this column.
Now look at this view you created. With the view categories collapsed, look for any number greater that 1 to determine which documents are duplicates.
I think what you are asking is not how to identify the duplicates - but how to find out which of them are parent documents. So basically you would create a view as Steve suggests - but instead of putting a constant of 1 into the second column I would suggest putting either #DocChildren (for immediate responses) or #DocDescendants (for all responses and responses to responses).
If I understand your logic then all the ones returning 0 (zero) are child documents and those returning 1 or higher would be parent documents. Of course you could also use an item on the document in your view formula - if it only exists on the parent doc (or its value can tell that it is a parent doc)
View selection formulas act on only one document at a time. They cannot perform lookups. They have no way to compare two documents. There is therefore no possible way for a view to identify duplicates.
A view can, as per the other answers, categorize documents based on common values. If there is a single field that is supposed to be unique across all documents, you can categorize on that field. That will give you a visualization of the duplicates, but it won't filter them in or out.
The only way for a view to filter duplicates - either to show only duplicates, or to exlude duplicates - would be if you run an agent that reads all documents, looks for those that are duplicates, and marks them with a special field value - e.g., IsDuplicate = 1. Once you do that, you can create a view that selects all documents with IsDuplicated = 1, or a view that excludes IsDuplicated = 1.

Can I get relating resources by SharePoint REST API?

There is an API to get relating resources in OData, the Url likes this: http://services.odata.org/V4/(S(34wtn2c0hkuk5ekg0pjr513b))/TripPinServiceRW/People('russellwhyte')/Trips(0).
Can I use it in SharePoint, or is there any other API likes this to get relating resources?
Thank you for your advises!
P.S. I know that I can use Lookup field and Expand to get resources, but it cannot meet my requirements.
I have List A and List B, List B is a task list. so how can I get relating tasks when I get each item form List A by one request?
I know that I can use expand, likes ~/_api/web/lists/getbytitle('List B')/items?$select=ListA/Title,ListA/Field0...&$expand=ListA. But I don't want to get data from List B, cause I need to filter data by current user's permissions in List A.
Since the lookup is in List B and you are querying List A there is not one request to retrieve the info you are looking for. If the Lookup was in List A you could see all the List B items. Without that, you need to first query all the List B items and return all the List A item ID's, then query List A.
_api/web/lists/GetByTitle('List B')?$select=lookupColumn/Id&$expand=lookupColumn/Id
_api/web/lists/GetByTitle('List A')?$filter=Id eq 'someID' or Id eq 'someID2'

Combining Results from 2 Queries. 1 of Which is a Joined Query

I have 2 list's that display data and provide totals.
One is a joined query, the other is a single query
I have tried to join the joined query and the single query but i can't get it to work.
Im trying to calculate a return rate. first list produces a total return amount for each salesman. The second produces total sales for each salesman.
In the 3rd list im trying to add and divide the totals to get my return rate.
This can be achieved using master details report.
A great simple example can be found in the following video tutorial here:
Cognos 10 Training - Master Detail Report
The basic steps are:
Create your master list and drag items into the list.
Drag additional list as a new column of the master list. So it should look like this:
Drag items to this list.
Now, make sure both queries contains the data item you want to join on. This data item does not have to appear in the list/s, but it must be part of both queries.
Select any item in the detail list and from the menu pick Data->Master Detail Relationships...
Press the new link button and create the relationship between the 2 queries.
That's itm run the report and see the results.
A deeper documentation can be found on Cognos official documentation is here:
Create a Master Detail Relationship

Display column from one Sharepoint list into another list

I have one Sharepoint list that contains training courses and duration (in hours). I have another list where users can enter the training they have and plan to take (using a Lookup column connected to the first list)
Is there a way I can bring over that Hours column to display on the second list? I only have access to the vanilla web parts and SPD, and I am not allowed to add third-party stuff (solutions/web parts) on the SP servers.
I just need that Hours column to appear in the list itself without users needing to click the lookup field (course title)
If you have multiple column field type and you use that as lookup field. You can get two column values in one field. It will show up as two different columns on list but you will need render templates for input forms. Check this out for basic idea
http://msdn.microsoft.com/en-us/magazine/dd727508.aspx#id0450138
Create a field type for course list
Create render template for MCV and extend SPFieldMultiColumnValue
Make that field as Lookup Column
You have to check if you can do second step using SPD only. Also another way to do it is using Multiple column lookup field
HTH

Can I create a COUNTIF calculated column in SharePoint?

Is there a way to create a SharePoint calculated column that returns a count of the number of entries in a list? So If I have 3 customers in my list with the company "Starbucks" I'd like the field to return "3"
(Edited some wording for clarity per suggestion from dariom).
You may be able to get what you want with another list using a not-so-well-known variation of a lookup column.
Let's say you have a list called Companies with values in the title column like "Starbucks", "Peets", etc. Now you also have the Customers list you refer to, but the "Company" column is a lookup column pointing to the title column in the Companies list.
You can add a count very similar to what you described to your Companies list. Go to your Companies list, add a column of type "Lookup" referring to the Customers list and you'll notice that in the drop-down area where you define the lookup if you point back to the Customers list, you'll have a new option called "Count Related". This is here automatically because it recognizes that the Customers list has a lookup pointing back to this one. Select that Count Related option and now your Companies list will have a column counting how many customers are associated with that company.
No coding, Javascript hacks, or anything. Just hidden SharePoint auto-magic.
No, I don't think there's a way to do this using the out-of-the-box calculated column.
Some other ways you could accomplish this are:
Create a view for your list that with a group by on the company field and include the total count. This is easiest, but might not be exactly what you're looking for.
Create a custom column type that executes a CAML query to find items that you're interested in. There is a learning curve if you've not done it before and if the list that you're adding this custom column to has lots of rows, you'll be executing a query for each row which is inefficient - it'll be OK for a small number of rows.
Use an event handler on the list that updates a column value each time a new item is added or removed from a list. This is easier, but can also be inefficient if you have a large number of items in your list.
As dariom said (damn my slow typing skills, +1!), only the current row can be operated on with calculated columns by default in SharePoint. There are a couple of documented workarounds involving SharePoint Designer or jQuery, though.
You can get a Count of specific list items in an XSLT Data View
To do this you will need SharePoint Designer.
Right click on your SharePoint List view (ensure the list view contains the field you want to filter by) select convert to XSLT Data View. Then in the Data Source Windows select Data Source Tab and drag and drop the field you want to get a total on for the specific items into where you want it displayed in your XSLT Data View. Click on the numerical value that is showing you should get a lightening bolt icon, select the drop down and choose Count, then select again and choose Filter. Select "Click here to add a new clause" then choose your field name again and enter your unique value as Starbucks and click OK, you can repeat this process for other fields you want the totals on. You will now see the total number of Starbucks items in the list.
I got something similar to work in a way similar to Niall. Basically, I:
Based on the source list, created a Data View Web Part (DVWP) on a "test" web
part page.
Added the footer column, which gives a count.
Set the filter for my conditions (i.e., the items I want to count).
In the code, deleted the recurring items row.
I was left with just the footer, which displayed a filtered count for all the list items. I further customized the footer by taking out the shaded background. Finally, I exported this web part and imported it onto the page where I wanted users to see a total of items in the list (which met the criteria).

Resources