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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
mh2587
Super User
Super User

Difference between values in same column

Hi I hope you are Doing well I am trying to calculate the difference of followers like the expected difference  any one who help me in this 

thank you

 

 

MonthSocial PlatformFollowersExpected Difference
AprilFacebook3030
MayFacebook33431
JuneFacebook347-13
JulyFacebook350-3
AugustFacebook366-16
SeptemberFacebook371-5
OctoberFacebook374-3
NovemberFacebook389-15

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @mh2587 ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a calculated column to get the month number

 

Month Number = SWITCH('Table'[Month],"January",1,"February",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)

 

2. Create a measure or calculated column to get the difference

 

Expected Difference = 
VAR _premonth =
    CALCULATE (
        MAX ( 'Table'[Month Number] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Month Number] < EARLIER ( 'Table'[Month Number] )
        )
    )
VAR _prefol =
    CALCULATE (
        SUM ( 'Table'[Followers] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Month Number] = _premonth )
    )
RETURN
    IF ( ISBLANK ( _prefol ), 0, 'Table'[Followers] - _prefol )

 

yingyinr_1-1639649641792.png

Best Regards

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @mh2587 ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a calculated column to get the month number

 

Month Number = SWITCH('Table'[Month],"January",1,"February",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)

 

2. Create a measure or calculated column to get the difference

 

Expected Difference = 
VAR _premonth =
    CALCULATE (
        MAX ( 'Table'[Month Number] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Month Number] < EARLIER ( 'Table'[Month Number] )
        )
    )
VAR _prefol =
    CALCULATE (
        SUM ( 'Table'[Followers] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Month Number] = _premonth )
    )
RETURN
    IF ( ISBLANK ( _prefol ), 0, 'Table'[Followers] - _prefol )

 

yingyinr_1-1639649641792.png

Best Regards

mh2587
Super User
Super User

@amitchandak @AlexisOlson Can you guys help me in this will be appreciated


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



amitchandak
Super User
Super User

@mh2587 , 

hope you have date else create date column like

date = datevalue("01-"&[Month] &"-2021")

then create a new column like
new column =
var _max = maxx(filter(Table, [Date] <earlier([Date])),[Followers])
return
[Followers] - maxx(filter(Table, [Date] = _max ),[Followers])

 

 

In case you need measures , you can use time intelligence with date table  

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Its not working giving the same value in the output

diff.PNG


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



@mh2587 , Sorry , My ba. In max you have to return date

 

new column =
var _max = maxx(filter(Table, [Date] <earlier([Date])),[Date])
return
[Followers] - maxx(filter(Table, [Date] = _max ),[Followers])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Still not getting the desired output

market 2.PNG


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.