Forum Discussion
Anonymous
6 years agoNot applicable
Filter Changes in Rows
I have Salesforce data from reports that are run weekly. I want to get a series of rows that have shown any change since the previous week. Sample Data: Opportunity ID Sales Rep Stage Reve...
- 6 years ago
Hi Anonymous
if an Opportunity ID only have increasing or equal values for stage, meaning it will not go e.g. from stage 3 to stage 2, you can write a calculated column like this:
Has changed = CALCULATE ( MAX ( 'Table'[Stage] ), FILTER ( ALL ( 'Table' ), 'Table'[Opportunity ID] = EARLIER ( 'Table'[Opportunity ID] ) && 'Table'[Report Date] < EARLIER ( 'Table'[Report Date] ) && 'Table'[Stage] <> EARLIER ( 'Table'[Stage] ) ) )If not you could write it like this:
Changed since last update = VAR _oid = CALCULATE ( SELECTEDVALUE ( 'Table'[Opportunity ID] ) ) VAR _currentDate = CALCULATE ( SELECTEDVALUE ( 'Table'[Report Date] ) ) VAR _prevDate = CALCULATE ( MAX ( 'Table'[Report Date] ), FILTER ( ALL ( 'Table' ), 'Table'[Opportunity ID] = _oid && 'Table'[Report Date] < _currentDate ) ) VAR _currentStage = CALCULATE ( SELECTEDVALUE ( 'Table'[Stage] ) ) VAR _prevStage = CALCULATE ( VALUES ( 'Table'[Stage] ), FILTER ( ALL ( 'Table' ), 'Table'[Opportunity ID] = _oid && 'Table'[Report Date] = _prevDate ) ) RETURN IF ( _currentStage <> _prevStage && NOT ( ISBLANK ( _prevstage ) ), 1, 0 )cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Anonymous
6 years agoNot applicable
sturlaws I had left that part out as our sales reps sometimes do not fully fill out fields in Salesforce, meaning that an Opportunity can have a blank stage when it is first created. If I include the NOT ISBLANK clause, will it be problematic for such Opportunities?