How to Display KPI Card Widget for Month-to-Month Comparison in Bold BI
This article will guide you through the process of creating a KPI Card widget in Bold BI that displays the difference between the current month and the previous month.
Steps to Create the KPI Card Widget
Step 1: Create Expressions
Consider you have date column named CreatedDate
and values in Value
. Create the following expressions in Bold BI which helps to compare the values between previous and current month.
-
Current Month:
DATEPART("MM",TODAY())
The above expression returns the current month.
-
Created Month:
DATEPART("MM",[CreatedDate])
The above expression returns the month of the
CreatedDate
column value. -
Current Year:
DATEPART("YYYY",TODAY())
The above expression returns the current year
-
Created Year:
DATEPART("YYYY",[CreatedDate])
The above expression returns the year of the
CreatedDate
column value. -
Year of Previous Month :
if([Current Month]=1,[Current Year]-1,[Current Year])
The above expression is used to calculate the year of previous month. For example, If the current month is Jan 2023 then the previous moth is Dec 2023. So that the year of previous month
Current Year - 1
which is 2022. If the current month is Mar 2023, then the year of previous month is Feb 2023 and the year is 2023 which isCurrent Year
. -
Previous Month:
if([Current Month]=1,12,[Current Month]-1)
The above expression check if the month is
Jan
then it returnsDec
as12
other wise returnsCurrent Month-1
-
Current Month Values:
if([Created Month]=[Current Month] AND [Created Year]=[Current Year],[Value],0)
The above expression check if the date is current month and current year, then it will return the value otherwise 0.
-
Previous Month Values:
if([Created Month]=[Previous Month] AND [Created Year]=[Year of Previous Month],[Value],0)
The above expression check if the date is previous moth and the year is year of previous month, then it returns the value otherwise 0.
Replace you column name in
CreatedDate
andValue
to calculate the difference between current and previous month.
Step 2: Assign Expressions to KPI Card
Assign the Current Month and Previous Month expressions to the KPI card as shown in the image below:
Now, the KPI Card widget will display the difference between the current month and the previous month.