*** NOTE: ALL INFORMATION IS ACCURATE AT DATE OF PUBLISHING ***
When using Forms Pro and sharing surveys to request feedback, the goal is to get responses, and the more you get, the better in terms of being able to analyse and improve. With the standard level of responses (meaning you aren’t paying any extra), you get 2,000 a month. So how do you keep an eye on that and make sure you know how many you have received each month? Let’s create a Survey Response dashboard to give us that insight.
The first thing we are going to do is create a new solution. If you aren’t sure how check out this post that walks through the steps. If you already created the solution from the previous post, you can just use that one instead and add to it! Add the Business Unit entity to the solution, then add a new rollup field called Survey Responses. use the Forms Pro survey responses (Owning Business Unit) related entity, and use the count aggregation on the entity.
Next, we are going to add the Business Unit entity to our model-driven Power App. If you have never created one of these, or don’t already have one, check out the Microsoft documentation here. Once you’ve got your app in edit mode, select to add a new entity.
Search for the Business Unit and add it.
Once you’ve added it to your app, open up the site map and add the link to the Business Unit entity from there.
Now that we’ve done that, we can add the field to our form and set it to use the radial knob component. We will set the min and step to zero, and bind the max to the survey responses field.
Now we can see what it looks like. That’s the total number of survey responses. However, we want to know how many responses we have for the current month… so we need to do a bit more to it.
Let’s add in a few more fields. We’ve already got the Survey Responses field, but we will add in a Survey Responses MTD (month to date) and a Survey Responses YTD (year to date). These will just be regular whole number fields. In addition, add in four date fields like you see below. Then add them to the Business Unit form in your solution.
Right, moving on, we need a couple of flows created using Power Automate. Again, starting from your solution, select add a new flow. The first one will update the four date fields we added to the Business Unit entity. We will run this each month, so the trigger will be a schedule that starts on the first of the year. Next, we add two compose steps. We need to get the date for the start of the month, and a date for the end of the month. Use this expression for the start of the month:
startOfMonth(utcNow())
And this for the end of the month:
addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)
We could also use the following:
addDays(startOfMonth(addToTime(utcNow(), 1, 'Month')), -1)
Next, we are going to extract just the day and the month from the start of the month. We need to do a check to see if it’s the first of January. If it isn’t, we will just update the Current Month Start and the Current Month End dates. If it is, we will update the Current Year Start and the Current Year End fields in addition to the month fields. The expression below will extract the five characters that appear after the first dash ( – ) in the start of the month compose step. That should then give us the two-digit month, a dash and then the two-digit day.
substring(outputs('Start_Of_Month'), add(indexof(outputs('Start_Of_Month'),'-'),1),5)
Next we need to get the current year. Our expression is pretty much the same as the one above, but this time we want to get the first four digits.
substring(outputs('Start_Of_Month'), add(indexof(outputs('Start_Of_Month'),''),0),4)
We could also use the formatDateTime expression to get the year by using the following:
formatDateTime(outputs('Start_of_Month'), 'yyyy')
Now let’s add a List records step using the Common Data Service (CDS) current connector. Our query is to find the parent business unit, which will be the one where the Parent Business Unit field is empty, so use _parentbusinessunitid_value eq null in your filter query.
Now let’s do a condition check. Use the Output from the Current Day and Month step, and see if it is equal to 01-01. If it is, it must be the first of the year.
Add in a step on each side which is an Update step to update the business unit found in the list step above. On the yes branch, we will update all four of these fields with the appropriate outputs. On the no branch we will just update the month fields.
We will also set the survey responses fields to zero. Set both of these on the yes branch, and just the month value on the no branch.
Alright, nearly there! The flow above will take care of the dates, but we need something that will take care of adding the number of survey responses on a regular basis. We will add a new flow that counts the survey responses. Run this daily. We can run this right after midnight. We will then use a List records step from the CDS current connector to find all survey responses from yesterday. Use this as your filter query:
Microsoft.Dynamics.CRM.Yesterday(PropertyName='createdon')
Now we need to know how many survey responses there were. So we get use the following expression to get the length (the number) of the step above.
length(body('Get_Survey_Responses_From_Yesterday')?['value'])
The next step is to list the Business Unit in the same way we did in the last step, then add in an Update action to update the business unit found. Now, we need to add the number from above to the existing numbers in the Survey Responses MTD field and the Survey Responses YTD field. Use the following expressions (making sure you change the field names to match yours).
add(items('Apply_to_each')?['mvw_surveyresponsesmtd'], outputs('Count_Number_Of_Survey_Responses'))
add(items('Apply_to_each')?['mvw_surveyresponsesytd'], outputs('Count_Number_Of_Survey_Responses'))
Finally, we can step back and admire our work. We can now see the current month start and end dates, the current year and end dates, and the number of survey responses we have received for each. Keep in mind if you are creating this now, you will need to add in the correct number for the current month and year on those fields. Do that before you add the radial knob component and make it read only.
Check out the latest post:
Split Your Audience By Number Or Percentage In Customer Insights - Journeys
This is just 1 of 480 articles. You can browse through all of them by going to the main blog page, or navigate through different categories to find more content you are interested in. You can also subscribe and get new blog posts emailed to you directly.
Hi Megan-
First…YOU ROCK! Thank you for all your help.
The issue I’m having and can’t find anything out there when I search, is when I try to create the Rollup field on the Business Unit Entity, I’m getting an error. No error for Calculated…only for Rollup. And, it’s really generic, so I can’t figure out what it means. I’m on latest and greatest Online version. I’m the Sys Admin. I’ve tried in from Power Platform and Classic mode…same error. I’m able to create Rollups other places, so I know I haven’t reached limit in environment nor on the entity.
Any thoughts?
Hi Jennifer, thank you for your lovely comment! π When you say the error is generic, do you get anything on the error that you can click to download a file that contains more details? Typically you would get that with any error, and the log file tends to contain something in there that can point to what is causing the issue.