cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Livearus
Helper III
Helper III

Retrieve the last three entries from a SharePoint list and add them up

Hi, everyone,

 

I would like to create a flow which retrieves the last 3 entries from a SharePoint list and adds them up.

 

The reason for this is that every line in the SharePoint list is a daily report. At the end of the day there are three reports, each of which contains numbers (number columns as well as calculated columns).

 

I would like to combine these numbers and then output them in a table by email.

 

I have already managed to do this for a report. However, I have no idea how I can / should call up three reports so that they are added together in the flow.

 

The flow should be triggered by a button in the Power Apps.

 

Is anyone able to help me?

 

regards

Livearus

1 ACCEPTED SOLUTION

Accepted Solutions

I think you should be using Power BI to generate the report layout.  Power Automate Flow is not a best tool to design reporting output. You can definitely achieve it with some complex logic but you need to maintain it later. 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

View solution in original post

8 REPLIES 8
PrasadAthalye
Community Champion
Community Champion

Can you define how you decide what are last 3 entries? If you mean last 3 created entries, then you can order your GetItems action in desc order and in Top count mention 3. This will retrieve 3 recently created entries for you.

 

Since you would like to invoke it from Power Apps, you can use Power Apps trigger. Refer how to  Video from @RezaDorrani  

https://www.youtube.com/watch?v=emAhLzVG9bM&t=223s

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community
Livearus
Helper III
Helper III

Okay, thank you for the answer.

 

But how do I add up these entries? I just can't imagine how the flow will build up?

In fact, it makes even more sense at the moment if I can call up the respective data records from the last 3 entries individually, then output them in a table and add them up in the flow itself.

 

Because I still need the entries individually, i.e. there should be 3 columns in a table, in each of which the entries can be seen.

 

How do I have to build up the flow to make this happen?

I have already created the table with HTML / CSS in the E-Mail V2 Action. Here I would then insert the calls via expressions / dynamic content.

 

Here is how I set up the flow (very simply) for a report (namely the last one created / - or changed). It will probably not be that easy for the last three reports, but I have no approach at the moment. Maybe someone can also recommend a suitable video or something?

 

The one linked above is not specifically about the issue intended here, apart from the trigger.

 

sbReport_Single.JPG

 

regards

Livearus

Ok. Please refer below...

 

  • As mentioned above, sort GetItems in reverse order and with top count 3, you get latest 3 rows.
  • Then use select to generate Array of required columns with the title that you need.
  • Then use Create HTML table to convert it to HTML table
  • Finally use it within email.

PrasadAthalye_0-1627309802446.png

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

I've already thought of something like that. In the case of the individual reports, not the summary, I had also tried the step via the "Select" or "Create HTML Table" action. I came across the problem that, for example, percentage values ​​are not transferred correctly, or the date / time format is incorrect. It should be in UTC + 1 (Berlin ...), but for me it always hangs 2 hours behind.

 

I was able to fix this with the "AddTime" function, but this cannot be used in the "Select-Action" for the appropriate dynamic content. Here I can only access "body" and "value" in connection with expressions.

Another problem is that I needed a certain table format that cannot be easily solved with the "Create Table Action". I would have to use this "action" several times, in the end I decided to implement HTML / CSS completely in the "E-Mail V2 action".

 

But that is exactly what cannot be implemented with the last three entries. Especially since the entries should not simply be displayed one below the other. Somehow complicated, is there another solution instead of yours suggested, or can I manipulate here even more for my purposes?

 

By the way, how do I sort the retrieval according to the last three entries created? What do I have to write in "ODATA"?

 

FlowComplete.JPG

 

regards

Livearus

Many questions. 🙂 I will try to respond to some of them.

 

  • For Sorting, just mention column name and sort order. E.g. 
vendor desc
  • If you are not able to find a column in select you can write the expression like ... item()?['Title']
  • Can you explain what table format you are trying to put together? Create HTML table also allows Custom columns... If this does not help, you will have to declare a string variable and then loop through GetItems collection to generate table using HTML tags inside the loop using Append to string variable.

PrasadAthalye_0-1627392111055.png

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community


@PrasadAthalye wrote:

Many questions. 🙂 I will try to respond to some of them.

 

  • For Sorting, just mention column name and sort order. E.g. 
vendor desc
  • If you are not able to find a column in select you can write the expression like ... item()?['Title']
  • Can you explain what table format you are trying to put together? Create HTML table also allows Custom columns... If this does not help, you will have to declare a string variable and then loop through GetItems collection to generate table using HTML tags inside the loop using Append to string variable.

PrasadAthalye_0-1627392111055.png

 



As is the case with beginners. Thank you for your patience.

 

  • Sorting by column name somehow doesn't work. It should be filtered according to the "report time". The column name is: "Report-Time". If I now write "Report-Time desc" without double quotes, I get the error that it is an invalid expression. I also tried to put "Report-Time" in single quotation marks, the same result. What am I doing wrong?

 

  • With the "Select-Action" it is less about the fact that I cannot find a certain content, but much more that the conversion, the time zone / the format is wrong. I can't change that?

 

  • How I want to design the table, I'll try to explain it using the picture. The problem here is that I have empty cells or connected cells in places. Then there is the problem that in places I have to add the sum of the values ​​above or to the left of them. These are not calculated in SharePoint, but in the flow. Although the percentages are mapped in SharePoint, they are not transferred correctly, because they come from a calculated column, I also have to calculate this in the flow, based on the dynamic data next to it.

DaylieCompleteReport.JPG

PS: Another problem, you will soon be able to open your own forum here (just kidding aside from me). The CSS does not seem to work in the Outlook Desktop Client. Although CSS is activated there, formatting on classes, for example, is not displayed. However, there is also a problem with the "Create HTML Tabel Action". How am I supposed to assign classes here? I can only access the standard HTML tags (table, td, th etc.). It is funny that it is always displayed correctly on the web, also in my "home office" with desktop client, but not at work with Outlook desktop client.

 

regards

Livearus

I think you should be using Power BI to generate the report layout.  Power Automate Flow is not a best tool to design reporting output. You can definitely achieve it with some complex logic but you need to maintain it later. 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

That may be good, I think there are always tools that are more suitable. For me and the organization in which I work, the use of Power Automates or even SharePoint is a quantum leap (^^).

 

Apart from that, I don't have access to Power BI with my Office 365 subscription, apart from the trial version.

So I would stay with Power Automate for now.

 

I would be very happy if you could somehow help me with the above problems, but you can also understand if the effort is too great.

 

regards

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (1,815)