Forum Discussion
pedrohenriquewe
3 years agoRegular Visitor
Create a measure - help!
I have two tables: AllIssues: key Resolved GCL-2379 11/04/2023 GCL-2397 27/03/2023 GSX-2137 27/03/2023 AllHistory: key Status History New Value Start GCL-...
- 3 years ago
Ok,
Finally got the question.
So the below DAX function works. Same assumption as before regarding relationships between both tables.Total UP2 =VAR Sum_Table =FILTER(SUMMARIZE(AllIssues,AllIssues[key],AllIssues[Resolved],"Last Date",CALCULATE(MAX(AllHistory[History]),FILTER(AllHistory,AllHistory[History]<AllIssues[Resolved])),"Last Status",LOOKUPVALUE(AllHistory[Status],AllHistory[History].[Date],CALCULATE(MAX(AllHistory[History]),FILTER(AllHistory,AllHistory[History]<AllIssues[Resolved])))),[Last Status]="UP")RETURNCOUNTROWS(Sum_Table)
The summarize function creates the table you see beside the card (where the Total UP 2 is displayed). This summarized tables look for the last date before the 'resolved' date and then does a lookup for that status. Complete function then does a count row filtering un Status=UP.
pedrohenriquewe
3 years agoRegular Visitor
Hello!
"Right Before" means the last Status before "Resolved" must be "UP". It does not matter if it was 10 days ago or 1000 days ago.
The measure have to count just two lines (Distinctcount by key).
| GCL-2379 | UP | 16/03/2023 |
| GSX-2137 | UP | 20/03/2023 |
AlanFredes
3 years agoResolver IV
Ok,
Finally got the question.
So the below DAX function works. Same assumption as before regarding relationships between both tables.
Total UP2 =
VAR Sum_Table =
FILTER(
SUMMARIZE(
AllIssues,
AllIssues[key],
AllIssues[Resolved],
"Last Date",CALCULATE(MAX(AllHistory[History]),FILTER(AllHistory,AllHistory[History]<AllIssues[Resolved])),
"Last Status",LOOKUPVALUE(AllHistory[Status],AllHistory[History].[Date],CALCULATE(MAX(AllHistory[History]),FILTER(AllHistory,AllHistory[History]<AllIssues[Resolved])))
),
[Last Status]="UP"
)
RETURN
COUNTROWS(Sum_Table)
The summarize function creates the table you see beside the card (where the Total UP 2 is displayed). This summarized tables look for the last date before the 'resolved' date and then does a lookup for that status. Complete function then does a count row filtering un Status=UP.
The summarize function creates the table you see beside the card (where the Total UP 2 is displayed). This summarized tables look for the last date before the 'resolved' date and then does a lookup for that status. Complete function then does a count row filtering un Status=UP.