Forum Discussion
Average from latest
- 10 years ago
hi Anonymous
1: Create a Summarize Table
PROJECTS-LASTAUDIT = SUMMARIZE(Audits;Audits[ProjectID];"AVG-LAST AUDIT"; CALCULATE(AVERAGE(Audits[Score]);filter(Audits;Audits[AuditDate]=Max(Audits[AuditDate]))))
2: Create a Measure Average
AVG-LASTAUDIT-PROJECTS = AVERAGE('PROJECTS-LASTAUDIT'[AVG-LAST AUDIT])
Replace with your fields & Table name
The average result is different because you highlighted twice rows of 433PED 8/6 and 14/06
EDIT: If you want all in only a measure
Medida2 =
AVERAGEX (
SUMMARIZE (
Audits;
Audits[ProjectID];
"AVERAGE-LASTAUDIT"; CALCULATE (
AVERAGE ( Audits[Score] );
FILTER ( Audits; Audits[AuditDate] = MAX ( Audits[AuditDate] ) )
)
);
[AVERAGE-LASTAUDIT]
) - 10 years ago
Anonymous go with Vvelarde solution from the EDIT:
Good job! Vvelarde
Here you can copy this one has same table name and columns (I think) as yours... Good Luck! :smileyhappy:
Measure = AVERAGEX ( SUMMARIZE ( ProjectAuditsDB, ProjectAuditsDB[ProjectID], "Average of Last Audit", CALCULATE ( AVERAGE ( ProjectAuditsDB[Score] ), FILTER ( ProjectAuditsDB, ProjectAuditsDB[AuditDate] = MAX ( ProjectAuditsDB[AuditDate] ) ) ) ), [Average of Last Audit] ) - 10 years ago
hi Anonymous
Summarize function like his name says create a summary of the table grouping by 1 or several columns and you can use a function to find or calculate something. In the previous measure or table you are grouping all rows by Project ID and calculate the average of every project ID.
Now for add a column with the last date for every project id you should add to the formula:
SummarizeTable=Summarize(Table; GroupField (In your case: ProjectID);Expresion(The average);"Last Date"; LASTDATE(Audits[AuditDate]))
hi Anonymous
Average from Latest = CALCULATE(AVERAGEA(ProjectAuditsDB[Score]),Filter(ProjectAuditsDB; ProjectAuditsDB(AuditDate)=MAX(ProjectAuditsDB[AuditDate]))
Many thanks for the reply
the following
= CALCULATE(AVERAGEA(ProjectAuditsDB[BIM Quality Score],FILTER(ProjectAuditsDB,ProjectAuditsDB[AuditDate]=MAX(ProjectAuditsDB[AuditDate]))))
renders this error
"Too many arguments were passed to the AVERAGEA function. The maximum argument count for the function is 1"
What does this mean?
- Vvelarde10 years ago
Community Champion
) is missing before the filter
= CALCULATE(AVERAGEA(ProjectAuditsDB[BIM Quality Score]),FILTER(ProjectAuditsDB,ProjectAuditsDB[AuditDate]=MAX(ProjectAuditsDB[AuditDate]))))
- Anonymous10 years agoNot applicable
including the ) produces a different error
The syntax for ')' is incorrect. (DAX(CALCULATE(AVERAGEA(ProjectAuditsDB[BIM Quality Score]),FILTER(ProjectAuditsDB,ProjectAuditsDB[AuditDate]=MAX(ProjectAuditsDB[AuditDate])))))).
- Vvelarde10 years ago
Community Champion
Delete ) at the End of the DAX Formula. This error is saying that you have too many ) at the end