Forum Discussion
Create new measure to compare values from two dates
- 5 years ago
Hi, AFra
This took me some time, but I got the results.
Create the following measures:
the Date:_LastDate = VAR _top1 = TOPN ( 1, ALL ( 'Table' ), [Reporting date], DESC ) RETURN MAXX ( _top1, [Reporting date] )_previousDate = VAR _t = FILTER ( ALL ( 'Table' ), 'Table'[Reporting date] < [_LastDate] ) VAR _preProject = TOPN ( 1, _t, [Reporting date], DESC ) VAR _preDate = SUMMARIZE ( _preProject, [Reporting date] ) RETURN MAXX ( _preDate, [Reporting date] ) // MAXX(FILTER(ALL('Table'),'Table'[Reporting date]<MAX('Table'[Reporting date])),[Reporting date])NewProject:
_NewProject = VAR _preProject = SUMMARIZE ( FILTER ( ALL ( 'Table' ), 'Table'[Reporting date] = [_previousDate] ), 'Table'[ID Project] ) VAR _if = IF ( MAX ( 'Table'[Reporting date] ) = [_LastDate], IF ( MAX ( 'Table'[ID Project] ) IN _preProject, BLANK (), 1 ) ) RETURN _ifHouse, RP date, Status:
just change the distinctount field_ChangeStatus = VAR _count = SUMMARIZE ( FILTER ( ALL ( 'Table' ), 'Table'[Reporting date] >= [_previousDate] ), [ID Project], "Count", DISTINCTCOUNT ( 'Table'[Status ] ) ) VAR _Change = FILTER ( _count, [Count] > 1 ) VAR _Project = SUMMARIZE ( _Change, [ID Project] ) VAR _if = IF ( MAX ( 'Table'[Reporting date] ) = [_LastDate], IF ( MAX ( 'Table'[ID Project] ) IN _Project, 1, BLANK () ) ) RETURN _ifResult:
Please refer to the attachment below for details
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, AFra
This took me some time, but I got the results.
Create the following measures:
the Date:
_LastDate =
VAR _top1 =
TOPN ( 1, ALL ( 'Table' ), [Reporting date], DESC )
RETURN
MAXX ( _top1, [Reporting date] )
_previousDate =
VAR _t =
FILTER ( ALL ( 'Table' ), 'Table'[Reporting date] < [_LastDate] )
VAR _preProject =
TOPN ( 1, _t, [Reporting date], DESC )
VAR _preDate =
SUMMARIZE ( _preProject, [Reporting date] )
RETURN
MAXX ( _preDate, [Reporting date] )
// MAXX(FILTER(ALL('Table'),'Table'[Reporting date]<MAX('Table'[Reporting date])),[Reporting date])
NewProject:
_NewProject =
VAR _preProject =
SUMMARIZE (
FILTER ( ALL ( 'Table' ), 'Table'[Reporting date] = [_previousDate] ),
'Table'[ID Project]
)
VAR _if =
IF (
MAX ( 'Table'[Reporting date] ) = [_LastDate],
IF ( MAX ( 'Table'[ID Project] ) IN _preProject, BLANK (), 1 )
)
RETURN
_if
House, RP date, Status:
just change the distinctount field
_ChangeStatus =
VAR _count =
SUMMARIZE (
FILTER ( ALL ( 'Table' ), 'Table'[Reporting date] >= [_previousDate] ),
[ID Project],
"Count", DISTINCTCOUNT ( 'Table'[Status ] )
)
VAR _Change =
FILTER ( _count, [Count] > 1 )
VAR _Project =
SUMMARIZE ( _Change, [ID Project] )
VAR _if =
IF (
MAX ( 'Table'[Reporting date] ) = [_LastDate],
IF ( MAX ( 'Table'[ID Project] ) IN _Project, 1, BLANK () )
)
RETURN
_if
Result:
Please refer to the attachment below for details
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AFra5 years ago
Helper III
thank you! it works nicely!!!