Articles in this section
Category / Section

How to Retrieve Previous Quarter Data in Bold BI

Published:

In Bold BI, it is possible to retrieve previous quarter data and calculate the percentage change without writing complex SQL queries. This can be achieved using the expression syntax provided for PostgreSQL, MS SQL Server, and MySQL.

Steps to Retrieve Previous Quarter Data

  1. Add Expression: Click on the ‘Add Expression’ button to start creating an expression.

    image.png

  2. Create Expression: Create an expression to get freight values based on the current quarter and the previous quarter.

    image.png

Syntax of Expressions

For PostgreSQL and all extract and rest data sources:

  • Freight- Previous Quarter: IF(Extract (Quarter from [Date]) = Extract(Quarter from DATESUB(90, TODAY())) AND YEAR([Date])=YEAR(DATESUB(90, TODAY())), [Freight], 0)
  • Freight- Current Quarter: IF(Extract (Quarter from [Date]) = Extract(Quarter from TODAY()) AND YEAR([Date])= CURRENTYEAR(), [Freight], 0)

For SQL Server:

  • Freight- Previous Quarter: IF(DATEPART(Quarter, [Date]) = DATEPART(Quarter, DATESUB(90, TODAY())) AND YEAR([Date])=YEAR(DATESUB(90, TODAY())), [Freight], 0)
  • Freight- Current Quarter: IF(DATEPART(Quarter, [Date]) = DATEPART(Quarter, TODAY()) AND YEAR([Date])=CURRENTYEAR(), [Freight], 0)

For MySQL:

  • Freight- Previous Quarter: IF(Quarter([Date]) = Quarter(DATESUB(90, TODAY())) AND YEAR([Date])=YEAR(DATESUB(90, TODAY())), [Freight], 0)
  • Freight- Current Quarter: IF(Quarter([Date]) = Quarter(TODAY()) AND YEAR([Date])=CURRENTYEAR(), [Freight], 0)
  1. Create KPI Expression: Create a KPI expression in widget properties for getting percentage values.
    image.png

image.png

This will allow you to see the percentage difference between the previous and current quarter.

image.png

References

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
RM
Written by Reethika Moovendhan
Updated:
Comments (0)
Please  to leave a comment
Access denied
Access denied