Forum Discussion
Last transaction dynamically
- 5 years ago
Hi Anonymous ,
Try the following formula:
Max_Date = CALCULATE( MAX('Table'[Date]), ALLSELECTED('Table'), GROUPBY('Table','Table'[ID]) )Measure = var result = CALCULATE( COUNT('Table'[ID]), FILTER( ALLSELECTED('Table'), 'Table'[Date] = [Max_Date] && 'Table'[Type] = MAX('Table'[Type]) ) ) return IF( HASONEFILTER('Table'[Type]), result, DISTINCTCOUNT('Table'[ID]) )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
WinnizIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Exactly, you described it perfectly. But with your measure i'm getting 2 transactions for a ID in the selected period
Hi Anonymous ,
Try the following formula:
Max_Date =
CALCULATE(
MAX('Table'[Date]),
ALLSELECTED('Table'),
GROUPBY('Table','Table'[ID])
)Measure =
var result =
CALCULATE(
COUNT('Table'[ID]),
FILTER(
ALLSELECTED('Table'),
'Table'[Date] = [Max_Date]
&& 'Table'[Type] = MAX('Table'[Type])
)
)
return
IF(
HASONEFILTER('Table'[Type]),
result,
DISTINCTCOUNT('Table'[ID])
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous5 years agoNot applicable
This measures works perfectly fine!! I just got another problem, i have got a subtype for each type and i cannot count them correctly if i add the subtype to the measure.
- Anonymous5 years agoNot applicable
I got it!
Measure = var resultType = CALCULATE( COUNT('Table'[ID]), FILTER( ALLSELECTED('Table'), 'Table'[Date] = [Max_Date] && 'Table'[Type] = MAX('Table'[Type]) ) ) var resultSubType = CALCULATE( COUNT('Table'[ID]), FILTER( ALLSELECTED('Table'), 'Table'[Date] = [Max_Date] && 'Table'[Type] = MAX('Table'[Type]) && 'Table'[SubType] = MAX('Table'[SubType]) ) ) return IF( HASONEFILTER('Table'[Type]), IF( HASONEFILTER('Table'[SubType]), resultSubType, resultType ), DISTINCTCOUNT('Table'[ID]) )