Forum Discussion
Steph83
3 years agoFrequent Visitor
How to calculate average
Good day, I closed my topic too quickly Here was my demand: How to calculate average age of a group of persons in XX years? I have a group of 300 people ("Artists") for who...
- 3 years ago
Hi Steph83
I hope the month column is Date formatted (I called [Date Added] in my code)Average age = VAR ReferenceDate = SELECTEDVALUE ( 'Slicer date'[Date] ) VAR Result = AVERAGEX ( CALCULATETABLE ( Artists, People[Date Added] <= ReferenceDate, CROSSFILTER ( Artists[Person ID], People[Person ID], BOTH ) ), DATEDIFF ( Artists[Date of birth], ReferenceDate, YEAR ) ) RETURN Result
tamerj1
Community Champion
3 years agoHi Steph83
do you mean you have a column in your rmtable that specifies the date when the record was added? And you want the date slicer selected date to filter all thoses records which were added on or before the selected date?
on the other hand I believe the provided measure shall not have any issue with your page and report filters. It should work with these filters just fine.
- Steph833 years agoFrequent Visitor
Hi tamerj1 ,
I have 2 tables:
1 - One table which lists the people month by month
2 - One table which contains all the data of the persons
Both table are linked by the person (1 to multiple)
- tamerj13 years ago
Community Champion
Hi Steph83
I hope the month column is Date formatted (I called [Date Added] in my code)Average age = VAR ReferenceDate = SELECTEDVALUE ( 'Slicer date'[Date] ) VAR Result = AVERAGEX ( CALCULATETABLE ( Artists, People[Date Added] <= ReferenceDate, CROSSFILTER ( Artists[Person ID], People[Person ID], BOTH ) ), DATEDIFF ( Artists[Date of birth], ReferenceDate, YEAR ) ) RETURN Result