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]))
Sean I think Vvelarde's latest edit looks like it's got you covered, unless I'm missing something. I haven't done any real testing though.
I didn't try ImkeF's solution yet because I found a DAX way after all. I still like my original solution. I mean it's bad, it's inefficient, it's hard to tell what the code is doing if you don't already know, and I'm definitely never using it again, but feel like it was at least a unique approach to the problem.
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]
)- Anonymous10 years agoNot applicable
You guys are great!
Many thanks for your time and patience Vvelarde and Sean
Am taking the first steps with the software (and the whole data analitics thing, to be honest, as my degree is in architecture. I mean designing buildings and all)
have been learning a lot by self teaching, watching tutorials and help files. But sometimes, most of the times,...ok...90% of the times, it is very hard to figure out on how can it be done.
Thanks a lot, once again.
J