Forum Discussion
get latest Value in Direct Query
Hello all,
I am using direct query. See attached sample data.
I want to show latest entries for each application, and its status (Is_error) and Actual response.
It shows correctly as below when I use only App Id and 'Latest dateTime' (
But as I add other fields like Is_Error, actual response , it shows both entries ( Is_error =0 and 1). I need to show only latest entry against the app id.
Sample data -
| App_Id | Request_Date | Request_TimeStamp | Response_TimeStamp | Is_Error | Actual_Response |
| 1 | 12/1/20 | 12:21:18 PM | 12:21:25 PM | 0 | Application is up |
| 1 | 12/1/20 | 12:21:14 PM | 12:21:23 PM | 0 | Application is up |
| 1 | 12/1/20 | 12:20:53 PM | 12:21:01 PM | 0 | Application is up |
| 2 | 12/1/20 | 12:22:23 PM | 12:22:33 PM | 0 | Application is up |
| 2 | 12/1/20 | 12:22:30 PM | 12:22:39 PM | 1 | Fail to connect URL |
| 2 | 12/1/20 | 12:21:55 PM | 12:22:07 PM | 0 | Application is up |
| 3 | 12/1/20 | 12:22:10 PM | 12:22:21 PM | 0 | Application is up |
| 3 | 12/1/20 | 12:21:22 PM | 12:21:32 PM | 0 | Application is up |
| 3 | 12/1/20 | 12:22:33 PM | 12:22:48 PM | 0 | Application is up |
| 4 | 12/1/20 | 12:21:58 PM | 12:22:08 PM | 1 | Fail to connect URL |
| 4 | 12/1/20 | 12:21:07 PM | 12:21:21 PM | 0 | Application is up |
| 5 | 12/1/20 | 12:20:55 PM | 12:21:01 PM | 0 | Application is up |
| 5 | 12/1/20 | 12:22:11 PM | 12:22:21 PM | 1 | Fail to connect URL |
Thank You!
Not sure if you are adding a calculated column or a measure. I would do it as a measure and not have a relationship to your icon table, using a measure like this.
Icon =
VAR thisstatus = [Status_Error]
RETURN
CALCULATE (
MIN ( Icon[IconURLColumn] ),
FILTER (
VALUES ( Icon[Icon_Key] ),
Icon[Icon_Key] = thisstatus
)
)Regards,
Pat
4 Replies
- mahoneypatMicrosoft Employee
Please try a measure like this instead of adding the Is_Error column, replacing table and column names as needed.
Status_Error = LASTNONBLANKVALUE(Table[ResponseTimeStamp]), MIN(Table[Is_Error]))
Regards,
Pat
- AnonymousNot applicable
Thanks mahoneypat for the help. it worked perfectly.
Now adding Up/ Down arrow in the same table visual istead of above one.
So created new column as -
KPI Ind = If(Table[Is_Error]=0,"1","2") which is linked to new table ICON column and ICON_Key (1- Up & 2- Down)
then again it showed both (0, 1) values of status_error field, as below.UP/Down icon need to show against latest status_error. Any pointers will be helpful.
- mahoneypatMicrosoft Employee
Not sure if you are adding a calculated column or a measure. I would do it as a measure and not have a relationship to your icon table, using a measure like this.
Icon =
VAR thisstatus = [Status_Error]
RETURN
CALCULATE (
MIN ( Icon[IconURLColumn] ),
FILTER (
VALUES ( Icon[Icon_Key] ),
Icon[Icon_Key] = thisstatus
)
)Regards,
Pat
- AnonymousNot applicable
Hi Anonymous ,
Based on your description, you can create a measure as follows.
Latest DateTime = MAX('Table1'[Request_Date])&" "&MAXX(FILTER(ALL('Table1'),[App_Id]=SELECTEDVALUE('Table1'[App_Id])),Table1[Request_TimeStamp])Result:
Hope that's what you were looking for.
Best Regards,
Yuna
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.