Comparing the current and previous rows

The goal of this example is to compare the values of one row with the next or previous row to compute a value for a variance or status column. In this example, the output of a factory for a given date needs to be compared to its previous days' output:

  1. Retrieve the essential columns into a query.
    • In this case, there are four factories, with each row representing the quantity output of a factory by date.
Figure 106: Source Data - Factory Qty by Day
  1. Use the Table.Sort() function to sort the table by Factory ID and then by Date.
Figure 107: Sorting Expression Applied Source
  • The order of columns ...

Get Microsoft Power BI Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.