Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
manojk_pbi
Helper V
Helper V

Current month vs previous month comparison in table

Hello,

 

I have single table with facts and dimensions data. I need to have table to show the kpis of projects for the current month and also the previous month along with indicators.

I am not getting how we can get the previous months kpi data along with current month when reporting month selected for current by user.

 

Attaching the sample data for referecne

PRJ NameDivisionBU UNITReportingDateKPI
PRJ1DIV1BU125-Jun60%
PRJ2DIV1BU125-Jun85%
PRJ3DIV1BU225-Jun79%
PRJ4DIV1BU325-Jun93%
PRJ5DIV1BU125-Jun85%
PRJ6DIV2BU125-Jun85%
PRJ7DIV2BU125-Jun60%
PRJ8DIV2BU325-Jun60%
PRJ1DIV1BU125-Jul85%
PRJ2DIV1BU125-Jul60%
PRJ3DIV1BU225-Jul60%
PRJ4DIV1BU325-Jul60%
PRJ5DIV1BU125-Jul60%
PRJ6DIV2BU125-Jul60%
PRJ7DIV2BU125-Jul85%
PRJ8DIV2BU325-Jul43%

Expected output: - Comparison is diff of Curr vs Prev

manojk_pbi_0-1755139200165.png

 

2 ACCEPTED SOLUTIONS
mdaatifraza5556
Super User
Super User

Hi @manojk_pbi

Can you please try the below steps to get your result ?

1. Create dim date table table and in that create a calculated column.

YearMonth = FORMAT(Dim_Date[Date], "YYYYMM")
Screenshot 2025-08-14 102242.png

 


2. Create three measure using below dax.

 

KPI_CurrMonth =
VAR SelectedMonth = MAX ( 'Dim_Date'[Date] )
RETURN
CALCULATE (
    AVERAGE ( 'Table'[KPI] ),
    FILTER (
        ALL ( 'Dim_Date' ),
        'Dim_Date'[YearMonth] = FORMAT ( SelectedMonth, "YYYYMM" )
    )
)
 
---------------------------------------------------------------------------------------------------- 
 
KPI_PrevMonth =
VAR SelectedMonth = MAX ( 'Dim_Date'[Date] )
RETURN
CALCULATE (
    AVERAGE ( 'Table'[KPI] ),
    FILTER (
        ALL ( 'Dim_Date' ),
        'Dim_Date'[YearMonth] =
            FORMAT ( EOMONTH ( SelectedMonth, -1 ), "YYYYMM" )
    )
)

 

 

 

------------------------------------------------------------------------------------

 

KPI_Comparison =
[KPI_CurrMonth] - [KPI_PrevMonth]
 
 
--------------------------------------------------------------------------------------
 
 
For the icon 
 
Click on chart then go for the conditinal formatting for KPI_Comparison

Screenshot 2025-08-14 095234.png

 

 

Result

Screenshot 2025-08-14 094804.png

 

If this answers your questions, kindly accept it as a solution and give kudos.

View solution in original post

Hi @manojk_pbi 

Create measure using below dax.


KPI_Comparison_1 =
IF (
    NOT ISBLANK ( [KPI_PrevMonth] ),
    [KPI_CurrMonth] - [KPI_PrevMonth]
)
 

Case1. when PreMth value is there

Screenshot 2025-08-14 113436.png

 

Case 2. If PrevMth values is not there

Screenshot 2025-08-14 113458.png

 

If this answers your questions, kindly accept it as a solution and give kudos.

View solution in original post

7 REPLIES 7
manojk_pbi
Helper V
Helper V

@mdaatifraza5556 , thanks for quick response and clarification on my doubts. The solution helped lot

 

mdaatifraza5556
Super User
Super User

Hi @manojk_pbi

Can you please try the below steps to get your result ?

1. Create dim date table table and in that create a calculated column.

YearMonth = FORMAT(Dim_Date[Date], "YYYYMM")
Screenshot 2025-08-14 102242.png

 


2. Create three measure using below dax.

 

KPI_CurrMonth =
VAR SelectedMonth = MAX ( 'Dim_Date'[Date] )
RETURN
CALCULATE (
    AVERAGE ( 'Table'[KPI] ),
    FILTER (
        ALL ( 'Dim_Date' ),
        'Dim_Date'[YearMonth] = FORMAT ( SelectedMonth, "YYYYMM" )
    )
)
 
---------------------------------------------------------------------------------------------------- 
 
KPI_PrevMonth =
VAR SelectedMonth = MAX ( 'Dim_Date'[Date] )
RETURN
CALCULATE (
    AVERAGE ( 'Table'[KPI] ),
    FILTER (
        ALL ( 'Dim_Date' ),
        'Dim_Date'[YearMonth] =
            FORMAT ( EOMONTH ( SelectedMonth, -1 ), "YYYYMM" )
    )
)

 

 

 

------------------------------------------------------------------------------------

 

KPI_Comparison =
[KPI_CurrMonth] - [KPI_PrevMonth]
 
 
--------------------------------------------------------------------------------------
 
 
For the icon 
 
Click on chart then go for the conditinal formatting for KPI_Comparison

Screenshot 2025-08-14 095234.png

 

 

Result

Screenshot 2025-08-14 094804.png

 

If this answers your questions, kindly accept it as a solution and give kudos.

How can we modify the KPI Comparison,  not to show anything in comparison and no arrows when prev is not present.

Hi @manojk_pbi 

Create measure using below dax.


KPI_Comparison_1 =
IF (
    NOT ISBLANK ( [KPI_PrevMonth] ),
    [KPI_CurrMonth] - [KPI_PrevMonth]
)
 

Case1. when PreMth value is there

Screenshot 2025-08-14 113436.png

 

Case 2. If PrevMth values is not there

Screenshot 2025-08-14 113458.png

 

If this answers your questions, kindly accept it as a solution and give kudos.

Hello @mdaatifraza5556 

 

I tried the sample provided by you but is not working in the main application. Then i realised there is a composite key "PRJ | MONTHYEAR" in the table. I am not getting the values now in the same row instead it is throwing in the another row.

 

This column is used to connect other tables to filter data based on project along with the rpeorting period.

 

Your advise is much appreciated.

 

MONTHKEYPRJ NameDivisionBU UNITReportingDateKPI
Jun-25|PRJ1PRJ1DIV1BU125-Jun60%
Jun-25|PRJ2PRJ2DIV1BU125-Jun85%
Jun-25|PRJ3PRJ3DIV1BU225-Jun79%
Jun-25|PRJ4PRJ4DIV1BU325-Jun93%
Jun-25|PRJ5PRJ5DIV1BU125-Jun85%
Jun-25|PRJ6PRJ6DIV2BU125-Jun85%
Jun-25|PRJ7PRJ7DIV2BU125-Jun60%
Jun-25|PRJ8PRJ8DIV2BU325-Jun60%
Jul-25|PRJ1PRJ1DIV1BU125-Jul85%
Jul-25|PRJ2PRJ2DIV1BU125-Jul60%
Jul-25|PRJ3PRJ3DIV1BU225-Jul60%
Jul-25|PRJ4PRJ4DIV1BU325-Jul60%
Jul-25|PRJ5PRJ5DIV1BU125-Jul60%
Jul-25|PRJ6PRJ6DIV2BU125-Jul60%
Jul-25|PRJ7PRJ7DIV2BU125-Jul85%
Jul-25|PRJ8PRJ8DIV2BU325-Jul43%

Hello @mdaatifraza5556 , thanks lot for your quick reply and the solution. Great !!.

 

I have one question, do we need to have separate Date table why cann't we use the date from the same table ? 

Hi @manojk_pbi 

It will also work, but it is a best practice to create a separate Date table.
In some cases, especially when using time intelligence functions it works more reliably and ensures proper results.

 

 

 

If this answers your questions, kindly accept it as a solution and give kudos.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors