Forum Discussion
Ages according to dates
Good morning
I need to calculate in a column, the ages that people had on the selected date. On the one hand I have the calendar where I mark the date I want, on the other I have the date of birth. The fact is that I put a column that is Min(calendar.date) - date of birth but as min of the calendar I do not take the date I select but the general minimum of the calendar. How can I solve it?
Thank you very much for a!
8 Replies
- davehus
Memorable Member
Hi Syndicate_Admin , If you are using a column then it won't work as the column is computed only at refresh. You could create a measure and use a combination of selectedvalue and and date diff below.
DATEDIFF(FIRSTNONBLANK('Age'[Date],1),SELECTEDVALUE('Date'[Date]),YEAR)Did I help you today? Please accept my solution and hit the Kudos button.- Syndicate_Admin
Administrator
But in addition to calculating the age at any given time, I have to represent that age in a graph like this and I can not calculate only the age of 1 person, but that of the whole set:
- AnonymousNot applicable
Hi Syndicate_Admin ,
Can you provide a simple PBIX file for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures. I look forward to your response.
How to Get Your Question Answered Quickly
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- Syndicate_Admin
Administrator
Ok, I would attach a pbix where you can see that I calculate the age that users had according to selected date but I do not know how to attach it. What button is it? What I don't know how to do is then represent the number of people who were 14 years old, those who were 15... and so on in a single graph. I would have to put the calculated age measure on the Y axis but it won't let me. I must also calculate the median age of the different people but filtandro since the same person can have several rows in the excel origin and as it is now, each row counts me for the calculation of the median of the age.
SpoilerMiddle age = AVERAGEX(Demands,[Age at the end of selected date])Distinct Persons = DISTINCTCOUNTNOBLANK(Claims[codi_exp])
Age at the end of the selected date = DATEDIFF(SELECTEDVALUE(Demands[fecha_nacimiento]),MAX(Calendar[Date]),YEAR)Thank you very much in advance for your help.
- AnonymousNot applicable
Hi Syndicate_Admin ,
Please try to use Onedrive (or google) share links .
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hi Syndicate_Admin ,
Please refer to my pbix file to see if it helps you.
Create a measure on calendar table first.
Measure = MAX(Calendario[Date])Then create a column.
Column eccionada = VAR _a = [Measure] RETURN DATEDIFF ( Demandas[fecha_nacimiento], _a, YEAR )If I have misunderstood your meaning, please provide your desired output with more details.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- Syndicate_Admin
Administrator
I have tried it but the data is not updated when the year changes and I want the ages to be updated again according to the selected year.