Forum Discussion
Anonymous
5 years agoNot applicable
Last transaction dynamically
Hello! I'm trying to find the lastest transaction in a dynamic period, I have checked another posts in the forum but they doesnt work. I have tried everything and I can get them but the dynamic cal...
- 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.
Anonymous
5 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.
Anonymous
5 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])
)