Total Rating, Average Ratings in PowerApps

Introduction

One of the most popular elements on social media platforms and for any user-interactive necessity is rating. As I was creating the ratings, I came to understand that accurate rating captures a great deal of validation.

Scenario

We'll adjust the display mode and add a rating control based on the specifications. Additionally, we'll record every rating as well as the project average rating.

Objective

The goal of this criteria is quite strict because numerous scenarios depend on the concept's grade. In notions like idea ratings or article ratings, it is helpful. We will develop a SharePoint list according to the specifications in order to calculate and project.

Step 1. The list structure would look like below.

A list structure might be created based on our requirements. I've made three distinct lists for this sample, and the data is displayed along with the list structure.

Article list structure

Article list structure

Article list content

Article list content

PostViewsOnArticle list structure

PostViewsOnArticle

PostViewsOnArticle Content

Article Content

The third list will save data from powerapps and the list structure looks like below.

Powerapps

Step 2. Design screen and form.

The snapshot below displays every article that has been submitted. By selecting an item, we can check its details as well as the number of views it has received. I've taken control of the gallery so that it displays all items.

Design screen

Below is the display form which shows the variable View value. Variable View value shows gallery-selected item details.

Variable View value

I'd like to display every possible viewpoint that individuals may have below. After viewing the details, we can click on each perspective to view it in more depth and score it. Once more, we will take advantage of Gallery control to display every view.

As you can see, I removed the title from the box label and added a button so that I could display the title as text while keeping it clickable.

Box label

Onselect of a button it should go to View description so the code looks like below.

View description

Step 3. Save the Logged User in a Global variable.

We keep logged-in user details in a global variable for performance improvement. Otherwise User(). The email could be used directly wherever required.

Global variable

Step 4. Add Rating list DataSource from SharePoint.

Add Rating List from SharePoint as DataSource.

So that the patch function can use this datasource to store the ratings.

DataSource

Screens

Step 5. DisplayMode property of Rating Control.

DisplayMode property of rating control at Article description page and views gallery.

DisplayMode property

Step 6. Default property of Rating Control.

Default property of Rating control.

Default property

Step 7. OnSelect property of Rating Control.

Below the OnSelect property, the function is optional in case it is needed. In my case, it is not required as the rating control is in view mode.

OnSelect property

Step 8. Create a new screen and a new form to show view details.

It is a representation of another method of rating control. What we saw in the above screen, little more in detail we will see in this screen. We will see validations on rating control in this scenario.

Create a new screen

Step 9. Add Rating Control to record ratings. Default Property of Rating Control.

The procedures for adding rating control and setting the default value to 0 are as follows. In contrast to the above, the validations will determine the display mode here.

The identical functionality described above will be present on a form where users can examine all of the item's details before selecting how to rate it. As a result, we'll include a rating control on the form below that displays your own ratings together with the total and average ratings as well as a patch of the ratings.

Add Rating Control

Step 10. Here Display mode will not be viewed directly. It will work depending on the validations.

Below is another example with validation to set Display mode.

Display mode

Step 11. OnSelect of Rating Control.

Since I have handled the displaymode, It is not required to do validation on OnSelect so I am patching directly to the list.

OnSelect of Rating Control

Step 12. Average Ratings.

Change the form mode to new or edit as needed. This step is just for a thought in case the form is not loaded correctly.

Average Ratings

Step 13. Total Ratings.

 Total Ratings

Conclusion

The above-mentioned example demonstrated how to use rating controls, how data is saved in a SharePoint list, how to extract the average rating, and how to display the total number of stars rated.


Similar Articles