Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hello all,
I have a column with DOB and need to find the person's age on June 1, 2019. I figured it out but I wanted to see if anyone had a more concise way of coding it.
= Table.AddColumn(#"...", "6/1/2019", each "6/1/2019", type date),
= Table.TransformColumnTypes(#"...",{{"6/1/2019", type date}}),
= Table.AddColumn(#"...", "Subtraction", each Duration.Days([#"6/1/2019"]-[DOB]), Int64.Type),
= Table.AddColumn(#"...", "Age@June_1_2019", each [Subtraction]/365, type number),
= Table.TransformColumns(#"...",{{"Age@June_1_2019", Number.RoundDown, Int64.Type}}),
Hi,
To know the total number of days, you may use this calculated column formula
=today()-[DOB]
The simplest way I can think of:
1. Select your DOB column
2. Select Add Column > Date > Age. Power Query will build for you the following formula:
= Table.AddColumn(#"Replaced Value1", "Age", each Date.From(DateTime.LocalNow()) - [DOB], type duration)
3. Replace DateTime.LocalNow() with your fixed date:
= Table.AddColumn(#"Replaced Value1", "Age", each Date.From("6/1/2019") - [DOB], type duration)
You can add a custom column with this formula to get the age on 6/1/2019
= Duration.TotalDays(#date(2019,6,1) - [DOB])/364
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
User | Count |
---|---|
88 | |
72 | |
69 | |
65 | |
57 |
User | Count |
---|---|
96 | |
92 | |
91 | |
75 | |
69 |