With date intelligence measures developed for the current and prior periods, growth or variance measures can be added to the dataset, comparing the two values. In the following example, a year-over-year (YOY) and a year-over-year year-to-date (YOY YTD) measure have been created based on the current year and prior year measures from the preceding section:
Internet Net Sales (YOY) = [Internet Net Sales (CY)] - [Internet Net Sales (PY)]
Internet Net Sales (YOY YTD) = [Internet Net Sales (YTD)] - [Internet Net Sales (PY YTD)]
Finally, growth percentage measures can be added, which express the variance between the current and prior period measures as a percentage of the prior period. The following measures reference the above YOY measures as the numerator within a DIVIDE() function:
Internet Net Sales (YOY %) = DIVIDE([Internet Net Sales (YOY)],[Internet Net Sales (PY)])
Internet Net Sales (YOY YTD %) = DIVIDE([Internet Net Sales (YOY YTD)],[Internet Net Sales (PY YTD)])
The DIVIDE() function returns a blank value if the denominator is zero or a blank value by default. The divide operator (/), however, will return an infinity value when dividing by zero or a blank. Given the superior error-handling behavior and performance advantages of DIVIDE(), the DIVIDE() function is recommended for computing division in DAX.