Forum Discussion
mh2587
4 years agoSuper 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 Month Social Platform Followers Ex...
- Anonymous4 years ago
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 )Best Regards
Anonymous
4 years agoNot 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 )
Best Regards