Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I need to calculate Age based on Date of birth("DOB") column, but it should change dynamically if we make a selection for any previous "Fiscal year" or "Fiscal month" in Qlik sense.
Looking forward to your suggestions.
Thanks & Regards,
Manmeet Dhawan
Can you please provide screenshot/ example of expected output?
HI @Manmeet
Try something like
IF(GetFieldSelections("Fiscal year") = 0 AND GetFieldSelections("Fiscal month") = 0,
Today() - "DOB",
DATE( '01/'&GetFieldSelections("Fiscal month")&'/'& GetFieldSelections("Fiscal year")) - "DOB"
)
Probably have to play with the date section to get the date formatted correctly
Hi Thanks for the response,
So, the expected output is like if my current age is 26.5(26 years 5 months) as on current year and month, I should get the same as my age in the "Age" column, But it should change as per the selection of previous year /month.
Ex: for 2020 same month if i check it should provide age as on that year/month i.e. 24.5 .
I hope i was able to explain it properly.
Thanks for your response, Trying to implement this logic not getting any result...
Can you please explain it with the help of a screenshot??
Hello,
Use age() in your expression.
try like age(date(max(your_date_field)),date_of_birth_field)
Regards,
Prashant Sangle
Thanks for your response,Using the above code also is not giving the correct results, I'm currently using below code to calculate age, it calculates correct for current year, But doesn't change when we select any other year/ month.
Num((Interval(date(Date#(today(),'MM/DD/YYYY'),'MM/DD/YYYY')
-Date(Date#(DOB,'MM/DD/YYYY'),'MM/DD/YYYY'),'DD')/365),'#,##.00')
as Age;
Kindly suggest.
Hi,
which datefield you are using to select date & year?
It will not gave you the answer which you are looking for because you are doing
today - DOB
You have to do datefield(which_you_are_selecting) - DOB
Also, can you explain what is wrong you are getting with my above solution. Only by saying it is not giving correct result won't help us to understand the issue.
Regards,
Prashant Sangle