PARALLELPERIOD

PARALLELPERIOD

How to Use the Power BI DAX function PARALLELPERIOD

In this article, we will discuss how to use the PARALLELPERIOD function in Power BI. We will start by defining the function and its syntax, and then we will provide examples of how it can be used in different scenarios.

What is the PARALLELPERIOD Function?

The PARALLELPERIOD function is a DAX function that allows you to shift the date context of a measure or a calculated column by a specified number of intervals. This function takes two arguments:

– **Interval**: The type of interval to use, such as “year”, “quarter”, “month”, “day”, “hour”, and so on.

– **Number of Intervals**: The number of intervals to shift the date context by, either positive or negative.

The function returns a table that contains the values of the specified measure or calculated column, shifted by the specified number of intervals.

Syntax of the PARALLELPERIOD Function

The syntax of the PARALLELPERIOD function is as follows:


PARALLELPERIOD(❰Time Column❱, ❰Number of Intervals❱, ❰Interval❱)


– **Time Column**: The name of the date column or time-intelligence function, such as DATEADD, that returns a date table.

– **Number of Intervals**: The number of intervals to shift the date context by, either positive or negative.

– **Interval**: The type of interval to use, such as “year”, “quarter”, “month”, “day”, “hour”, and so on.

Examples of Using the PARALLELPERIOD Function

Example 1: Comparing Sales for the Previous Month

Suppose you want to compare the sales of your products for the previous month. To do this, you can use the PARALLELPERIOD function as follows:


PrevMonthSales = CALCULATE(SUM(Sales[SalesAmount]), PARALLELPERIOD(DimDate[Date], 1, MONTH))


This measure calculates the sum of the sales amount for the previous month, using the PARALLELPERIOD function to shift the date context by one month.

Example 2: Comparing Sales for the Previous Year

Suppose you want to compare the sales of your products for the same month of the previous year. To do this, you can use the PARALLELPERIOD function as follows:


PrevYearSales = CALCULATE(SUM(Sales[SalesAmount]), PARALLELPERIOD(DimDate[Date], 1, YEAR))


This measure calculates the sum of the sales amount for the same month of the previous year, using the PARALLELPERIOD function to shift the date context by one year.

Example 3: Comparing Sales for a Specific Quarter

Suppose you want to compare the sales of your products for a specific quarter. To do this, you can use the PARALLELPERIOD function as follows:


QuarterSales = CALCULATE(SUM(Sales[SalesAmount]), PARALLELPERIOD(DimDate[Date], 0, QUARTER))


This measure calculates the sum of the sales amount for the current quarter, using the PARALLELPERIOD function to shift the date context by zero intervals.

Example 4: Comparing Sales for a Range of Dates

Suppose you want to compare the sales of your products for a range of dates. To do this, you can use the PARALLELPERIOD function in combination with the DATESBETWEEN function as follows:


RangeSales = CALCULATE(SUM(Sales[SalesAmount]), DATESBETWEEN(DimDate[Date], PARALLELPERIOD(DimDate[Date], -1, YEAR), PARALLELPERIOD(DimDate[Date], 0, YEAR)))


This measure calculates the sum of the sales amount for a range of dates, from the same date of the previous year to the current date of the current year, using the PARALLELPERIOD function to shift the date context by one year.

The PARALLELPERIOD function is a powerful tool that allows you to compare data across different time periods in Power BI. By using this function, you can analyze trends and patterns in your data over a specific period of time. In this article, we have discussed the syntax of the PARALLELPERIOD function and provided examples of how it can be used in different scenarios. With this information, you can now incorporate the PARALLELPERIOD function into your Power BI reports and gain valuable insights into your data.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

Subject

Your Name (required)

Company/Organisation

Email (required)

Telephone

Training Course(s)

Your Message

Upload Example Document(s) (Zip multiple files)