Forum Discussion
Get latest value based on max date
Hello!!!
I want to get the latest target based on the latest date and for the date format has time also, so basically the latest value based on max date and time.
The expeted output of this is 95, i have used max date funcation but it does not seem to work.
| Project Name | Modified Date | Target |
| BASIC | 13-Dec-22 14:00 | 95 |
| BASIC | 13-Dec-22 13:00 | 90 |
| BASIC | 13-Dec-22 12:00 | 85 |
Any suggest, how to get this working? Thanks a lot in advance!!
hi JCK2
try to plot a visual table with a measure of this:
Target2 =VAR _value = MAXX(TableName, TableName[ModifiedDate])RETURNMAXX(FILTER(TableName, TableName[ModifiedDate] =_value),TableName[Target])i tried and it worked like this:the dataset:
8 Replies
- JW_van_HolstResolver IV
_TargetMaxDate = VAR __filer = MAX('Table'[Modified Date]) VAR __target = CALCULATE(SELECTEDVALUE('Table'[Target]), 'Table'[Modified Date] = __filer) RETURN __target - FreemanZSuper User
it can be further simplified like this:
Target3 =VAR _value = MAX(TableName[ModifiedDate])RETURNMAXX(FILTER(TableName, TableName[ModifiedDate] =_value),TableName[Target]) - AnonymousNot applicable
With this I got What I wanted but one thing when I enable the total values the total the value is coming as Max value of both(in this case 95) instead of sum of both ( 96) .
Can you please help me with that.
- Walt1010Helper V
This (the Related Target calc) looks very promising, but when I try it I get the error "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."
Its confusing becasue the condition in my case definitely can only be satisfied by a single Date, and hence a single related value. I tried dividing it and first retreieving the latest data using LASTDATE, and then using that date to get the value, and it seemed to work.
- latimeriaSolution Specialist
Hi JCK2 ,
Something like this:
//get max date for 1 project
VAR MaxDate = calculate( max('table'[Modified Date]), allexcept('table, 'table'[project name]))
RETURN//get target for max date for the project. Instead of max, you can use min as you retrieve only 1 value
//assumpton: you have a relationship between table date & project date
calculate( max('table'[Target]), datetable[date] = MaxDate) - JCK2Helper III
Thanks everyone! let me try them 🙂