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.
Hi Anonymous ,
Try the following formula:
Measure =
var MaxDate =
CALCULATE(
MAX('Table'[Date]),
ALLSELECTED('Table'),
GROUPBY('Table','Table'[ID])
)
return
CALCULATE(
COUNT('Table'[Type]),
GROUPBY(
FILTER(
ALLSELECTED('Table'),
'Table'[Date] = MaxDate
),
'Table'[Type]
)
)
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.
Thank you!!
I see a problem in your measure, the first example is wrong because the total should be 2, and it shows 1.
- v-kkf-msft5 years agoCommunity Support
Hi Anonymous ,
Try the following formula:
Measure = var MaxDate = CALCULATE( MAX('Table'[Date]), ALLSELECTED('Table'), GROUPBY('Table','Table'[ID]) ) var result = CALCULATE( COUNT('Table'[Type]), GROUPBY( FILTER( ALLSELECTED('Table'), 'Table'[Date] = MaxDate ), '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.
- Anonymous5 years agoNot applicable
Your measure is amazing but I cant get it to work, with my real data i get a ID in 2 differents groups :S The example that i'm analyzing right now to check the measure is:
ID Date (DD/MM/YYYY) Type 1 06/03/2020 A 1 02/03/2020 A 1 19/12/2019 B - v-kkf-msft5 years agoCommunity Support
Hi Anonymous ,
Could you describe in detail what went wrong? What I understand is that there is only one latest status for each ID during the selected period. Therefore, the Total part is the total number of id in the time period.
Best Regards,
Winniz