cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Anonymous
Not applicable

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

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.

1 ACCEPTED SOLUTION
Community Support

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),
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.

5 REPLIES 5
Community Support

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),
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.

Anonymous
Not applicable

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.

Anonymous
Not applicable

Excelente. Gracias

Anonymous
Not applicable

Muchas gracias.

Voy a intentar

Super User

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.

Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling

Proud to be a Super User!

MCSA: BI Reporting