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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Alex35749
Regular Visitor

Calculating a difference between two periods

Hello Everyone. A bit of a background: in my work we rarely use actual calendar months (thus cannot use time intelligence functions), but we use periods instead as demonstrated in the sample dataset I have included. And currently I am struggling to find a way to calculate the difference in total revenue between one period and the period before it (i.e., period-on-period change) in Power BI. Could somebody please help me with that? I have included the desired result at the bottom of this post.

 

PeriodWeekRevenue
Period 1Week 110
Period 1Week 124
Period 1Week 267
Period 1Week 234
Period 1Week 378
Period 2Week 434
Period 2Week 454
Period 2Week 423
Period 2Week 567
Period 2Week 634
Period 2Week 654
Period 3Week 745
Period 3Week 778
Period 3Week 890
Period 3Week 8123
Period 3Week 812
Period 3Week 834
Period 3Week 95

 

Desired Result:

PeriodTotal RevenueRevenue Difference
Period 1213 
Period 226653
Period 3387121

 

So, I would like to see the difference in total revenue between one period and the period before it (Revenue Differnce column). For example, Period 3 - Period 2, Period 2 - Period 1 and so on. It is a similar concept to a month-on-month calculatinon. Any help would be appreciated. Thanks:)

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Alex35749 

 

you can try to create a measure

 

Measure =
VAR _last=maxx(FILTER(all('Table'),'Table'[Period]<max('Table'[Period])),'Table'[Period])
return if(_last="",BLANK(),sum('Table'[Revenue])-SUMX(FILTER(ALL('Table'),'Table'[Period]=_last),'Table'[Revenue]))
 
11.PNG
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@Alex35749 

 

you can try to create a measure

 

Measure =
VAR _last=maxx(FILTER(all('Table'),'Table'[Period]<max('Table'[Period])),'Table'[Period])
return if(_last="",BLANK(),sum('Table'[Revenue])-SUMX(FILTER(ALL('Table'),'Table'[Period]=_last),'Table'[Revenue]))
 
11.PNG
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




mugdha395290
New Member

Hi, @Alex35749 
First, group by Period in Power Query which will give you this-

mugdha395290_0-1720474794234.png

 

Add a column PeriodNumber -

mugdha395290_1-1720474872387.png

 

 

Next step will be to create a measure to calculate difference with previous revenue-

 

mugdha395290_0-1720475647648.png

It will give the desired output-

mugdha395290_1-1720475750809.png

Hope this helps 🙂

 
 
 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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