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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
carollyna205
Frequent Visitor

Calculating percentage change between last consecutive months

MonthABCDE
January5812312323423
February642342334434
March344553335656
April553334567778
Change

 

    

 

Hi, 

Let's say I have table like this. I am trying to add row at the en 'Change' which will show me precentage change between last 2 months, so basicaly formula (April-March)/March*100  how can I add this? Note that every month data will be refreshed and new row with new month will be added so I always want only change between current month and previous month % comparison. 

1 ACCEPTED SOLUTION

@carollyna205 

To play it safe (incase you have different years) it is better to have a YearMonth Calculated Column. 
YearMonth = FORMAT ( 'Table'[Date], "YYMM" )

 

then the measure for A for example would be


A Measure =
VAR Last2Months =
TOPN ( 2, VALUES ( 'Table'[YearMonth] ) )
VAR LastMonth =
MAXX ( Last2Months, 'Table'[YearMonth] )
VAR PenultimateMonth =
MINX ( Last2Months, 'Table'[YearMonth] )
VAR LastValue =
CALCULATE ( SUM ( 'Table'[A] ), 'Table'[YearMonth] = LastMonth )
VAR PenultimateValue =
CALCULATE ( SUM ( 'Table'[A] ), 'Table'[YearMonth] = PenultimateMonth )
RETURN
IF (
HASONEVALUE ( 'Table'[YearMonth] ),
SUM ( 'Table'[A] ),
FORMAT ( DIVIDE ( LastValue - PenultimateValue, PenultimateValue ), "Percent" )
)

View solution in original post

8 REPLIES 8
tamerj1
Super User
Super User

hi @carollyna205 

how does the source data look like? Are you utilizing a date table?

Each month I run Python script wchich adding data for current month, its basicly table with over 30k rows each month and each month that 3ok rows are added to previous file, so its one big file with 100k+ rows and aroung 40 columns. This visualisation is based on column Month and the columns A,B,C,D etc are columns for specific platforms. So at the end of May Python script will generate new data and row for May will show up and I would like to have always additional row on the end which calculate precetage of change between current month and previous month. If not possible to have it at the bottom of the table I dont mind having additional table with comparison only 

@carollyna205 

what date attributed columns do you have in your table?

Count of number of users - as values
Platform type - as columns

date format cell (month) - as rows

@carollyna205 

To play it safe (incase you have different years) it is better to have a YearMonth Calculated Column. 
YearMonth = FORMAT ( 'Table'[Date], "YYMM" )

 

then the measure for A for example would be


A Measure =
VAR Last2Months =
TOPN ( 2, VALUES ( 'Table'[YearMonth] ) )
VAR LastMonth =
MAXX ( Last2Months, 'Table'[YearMonth] )
VAR PenultimateMonth =
MINX ( Last2Months, 'Table'[YearMonth] )
VAR LastValue =
CALCULATE ( SUM ( 'Table'[A] ), 'Table'[YearMonth] = LastMonth )
VAR PenultimateValue =
CALCULATE ( SUM ( 'Table'[A] ), 'Table'[YearMonth] = PenultimateMonth )
RETURN
IF (
HASONEVALUE ( 'Table'[YearMonth] ),
SUM ( 'Table'[A] ),
FORMAT ( DIVIDE ( LastValue - PenultimateValue, PenultimateValue ), "Percent" )
)

Thank you, Overal it works but it using data from first 2 months instead of last 2 months, I know there is no BOTTOMN eqivalent to TOPN, do you have any idea how to solve this. I am new to PowerBi so still learning 

Actually I found solution for this, Thank you for help!

@carollyna205 

what date attributed columns do you have in your table?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.