Forum Discussion
Associate a max value with the original record
- 6 years ago
Hi Anonymous ,
You could try like this:
LatestSEQN = VAR CurrentID = SELECTEDVALUE ( 'Activity'[ID] ) VAR MAX_SEQ = MAXX ( FILTER ( ALL ( 'Activity' ), Activity[ID] = CurrentID ), 'Activity'[MaxSeq] ) RETURN IF ( MAX ( Activity[MaxSeq] ) = MAX_SEQ, MAX_SEQ, BLANK () )Count 1 = CALCULATE ( DISTINCTCOUNT ( Activity[ID] ), FILTER ( ALLEXCEPT ( Activity, Activity[PRODUCT_CODE] ), Activity[MaxSeq] = [LatestSEQN] ) ) Count 2 = COUNTX(Activity,[LatestSEQN])
Hi Anonymous ,
You could try like this:
LatestSEQN =
VAR CurrentID =
SELECTEDVALUE ( 'Activity'[ID] )
VAR MAX_SEQ =
MAXX (
FILTER ( ALL ( 'Activity' ), Activity[ID] = CurrentID ),
'Activity'[MaxSeq]
)
RETURN
IF ( MAX ( Activity[MaxSeq] ) = MAX_SEQ, MAX_SEQ, BLANK () )
Count 1 =
CALCULATE (
DISTINCTCOUNT ( Activity[ID] ),
FILTER (
ALLEXCEPT ( Activity, Activity[PRODUCT_CODE] ),
Activity[MaxSeq] = [LatestSEQN]
)
)
Count 2 = COUNTX(Activity,[LatestSEQN])
- Anonymous6 years agoNot applicable
Many thanks Xue, you nailed it!
Quick question if you have time. What is the difference infunctions for Count 1 and Count 2? Would I use under different conditions? When I tried on the larger data set and filtering on other conditions I get different counts. Count 2 appears to be the accurate count I need, although still validating this.
Cheers,
Ryan- v-xuding-msft6 years agoCommunity Support
Hi Anonymous ,
For "Count 1", I calculate based on ID. And for "Count 2", it counts the measure "LatestSEQN". I write two formulas because I don't know what your actual data like. If "Count 2" works for you now, you don't need to add other conditions.
- Anonymous6 years agoNot applicable
That's what I thought, but wanted to make sure I understood your logic correctly. Yes, I do want to count only "LatestSEQN". Thank you for clarifying.