Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hola, requiero de su ayuda para crear una columna personalizada en Power Query que me calcule la edad en años y meses, dando como parámetros una fecha de nacimiento y la fecha actual.
Ejemplo:
Fecha de nacimiento: 15/04/2018
Fecha Actual: 18/05/2020
Edad 7 años 7 meses
En Excel utilizaría la fórmula =sifecha(hoy();a1;"y") & " " & sifecha(hoy();a1;"m")
Pero en Powerquery sé que se puede utilizar una fórmula como Duration.Days..... pero no sé cómo hacerlo
Muchas gracias.
Solved! Go to Solution.
Hi @Anonymous
Create a query, then invoke the query into your table
(yourdate as date)=>
let
startdate=
if yourdate>Date.From(DateTime.LocalNow()) then null else yourdate,
MyYears=Number.RoundDown(Duration.TotalDays(Date.From(DateTime.LocalNow()) - startdate)/365),
month1=Date.Month(Date.From(DateTime.LocalNow()))-Date.Month(Date.AddYears(startdate,MyYears)),
mymonths=if month1<0 then 12+month1 else month1,
Concat =
Text.From(MyYears) & " Yrs " &
Text.From(mymonths) & " Months"
in
Concat
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Create a query, then invoke the query into your table
(yourdate as date)=>
let
startdate=
if yourdate>Date.From(DateTime.LocalNow()) then null else yourdate,
MyYears=Number.RoundDown(Duration.TotalDays(Date.From(DateTime.LocalNow()) - startdate)/365),
month1=Date.Month(Date.From(DateTime.LocalNow()))-Date.Month(Date.AddYears(startdate,MyYears)),
mymonths=if month1<0 then 12+month1 else month1,
Concat =
Text.From(MyYears) & " Yrs " &
Text.From(mymonths) & " Months"
in
Concat
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Muchas gracias.
Pero tengo una inquietud: Esta misma solución aplica para Power Query de Excel (lenguaje M)?
Porque la solución que me brindó es para Lenduaje DAX de Power Bi.
Excelente. Gracias
Muchas gracias.
Voy a intentar
If you will post this in the spanish group, it may translate it back to English for this group. The translation feature doesn't work when it is Spanish in the English forum.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingStarting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
29 | |
12 | |
12 | |
11 | |
8 |
User | Count |
---|---|
54 | |
27 | |
15 | |
14 | |
13 |