Parsware
All articles

Power Apps

Reports from a view

A Parsware report can read a Dataverse view instead of the whole table. The view decides which rows, in what order and with which columns, and it's something your makers already know how to build. Here's a report of urgent cases, filtered and sorted by a view.

The report preview in the Parsware designer: a page titled Urgent cases, Page 1 of 2, listing only urgent cases with their priority, next to the title "Reports from a view"

The report in the last article read every row of the Case table. Most reports don't want that. They want the open orders, this month's claims, the urgent cases, in a sensible order.

You could build that filter into the report. You don't need to: a Dataverse view already says it. A view has a filter, a sort order and a set of columns, it's a solution component, and anyone who builds model-driven apps already knows how to make one. So a Parsware dataset can simply name a view.

1. Make the view

Make the view the way you would for any model-driven app, in the maker portal under Tables, your table, Views. Ours is on the samples' Case table:

Name Urgent cases
Filter Status is Active, and Urgent equals Yes
Sort Priority, descending, then Subject
Columns Subject, Priority, Contact

Save and publish it. Here it is in the Parsware Samples app, 40 cases out of 200:

The Urgent cases view in the Parsware Samples app: Subject, Priority and Contact columns, sorted by priority, showing cases such as Meeting room display is blank and Printer offline in Reception, with Rows: 40 at the bottom

2. Point a dataset at it

Start a report as before: a new design in Designs with Kind set to Report, then Insert › Report page in the designer. We called ours Urgent cases.

Press Datasets, name the dataset (urgent), choose the Case table, and this time open View. The list is the table's own views, each with its type, and a search box above them. Choose Urgent cases and press Save.

The Datasets dialog: a dataset named urgent, Source Table view, Table Case, and View set to Urgent cases

That's the whole change. The dataset now reads the view's query instead of the whole table.

3. Bind to the view's columns

Set the repeater's Repeat over to urgent, then bind the row's text boxes as in the last article.

Open a Binding list and you'll notice it's shorter. For a whole table it offered every column Case has. For a view it offers only the columns the view selects: Case, Subject, Priority and Contact. A report can only print what the query returns, so the designer doesn't offer a column that would come back empty.

Text 14 selected inside the repeater, with the Report tab showing Binding set to Subject and Format set to text

We bound Subject and Priority, set the priority's Format to text, and set the title and the column headings.

4. Preview

Press Report:

The Report preview: Urgent cases, page 1 of 2, listing only urgent cases, the Normal ones first and then the Low ones, each sorted by subject

Three things came from the view, and none of them is in the report:

  • Which rows. 40 urgent cases, so two pages instead of eight.
  • What order. By priority, then by subject, exactly as the view sorts.
  • Which columns the designer offered for binding.

Why a view is usually the right answer

  • Change the view, and the report follows. Somebody adds a condition to Urgent cases and the report picks it up next time it runs, without opening the designer or publishing again.
  • It travels. A view is a solution component, so it moves to test and production alongside the report.
  • Security still applies. The report runs the view as the signed-in user, so it shows the rows that person could see in the view itself, and no others.

What a view can't do is add things up. A view returns rows. It has no total, count or average by group. For those, a report reads FetchXML, which is the next article.

The view, as Dataverse stores it

A view's filter and sort are FetchXML underneath, which is what the dataset actually runs. Urgent cases reads roughly like this:

<fetch>
  <entity name="par_case">
    <attribute name="par_subject" />
    <attribute name="par_priority" />
    <attribute name="par_contact" />
    <filter type="and">
      <condition attribute="statecode" operator="eq" value="0" />
      <condition attribute="par_urgent" operator="eq" value="1" />
    </filter>
    <order attribute="par_priority" descending="true" />
    <order attribute="par_subject" />
  </entity>
</fetch>

The <attribute> lines are why the Binding list offers only those columns, and the <order> lines are the report's order. (The column names are the sample's; your view writes its own.)

Views that make good report sources

View Filter A report it feeds
My open cases Owner is the current user, status active A personal work list to print at the start of a shift
This month's claims Submitted on in this month The monthly claims summary
Orders awaiting dispatch Status is approved, not yet shipped A picking list for the warehouse
Urgent cases Urgent, active A list for the daily stand-up

A view whose filter says the current user is especially useful: the same report prints each person's own list, because the view runs as whoever opens it.

Naming the view for the report

A view used by a report becomes something the report depends on, so it helps to make that visible:

  • Name it for what it selects, Urgent cases, not Report view 2.
  • Keep its columns to what the report prints, so nobody adds a column there expecting it to appear on paper without a binding.
  • Put it in the same solution as the report, so the two travel together.

Next

Totals with FetchXML: a grouped total computed by Dataverse and printed as a report. The whole series is in the reading list.