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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.