Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
albertan
Frequent Visitor

Combinar año y mes hasta fin de mes (EOM)

Hola, aprecio un consejo. Tengo un año en formato de texto y también mes en formato de texto (2 dígitos). ¿Cuál es la manera de convertir a fin de mes (en lenguaje M). Gracias

1 ACCEPTED SOLUTION
FrankAT
Community Champion
Community Champion

Hola @albertan

con datos de muestra simulados puede hacerlo de la siguiente manera:

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlDSUTKwVIqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Month = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", type text}, {"Month", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each Date.EndOfMonth(#date(Number.From([Year]),Number.From([Month]),1))),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Date", type date}})
in
    #"Changed Type1"

22-09-_2020_20-05-47.png

No te molestes con el formato de fecha que está localizado.

Con saludos amables desde la ciudad donde la leyenda del 'Pied Piper de Hamelin' está en casa
FrankAT (Orgulloso de ser un Datanaut)

View solution in original post

1 REPLY 1
FrankAT
Community Champion
Community Champion

Hola @albertan

con datos de muestra simulados puede hacerlo de la siguiente manera:

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlDSUTKwVIqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Month = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", type text}, {"Month", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each Date.EndOfMonth(#date(Number.From([Year]),Number.From([Month]),1))),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Date", type date}})
in
    #"Changed Type1"

22-09-_2020_20-05-47.png

No te molestes con el formato de fecha que está localizado.

Con saludos amables desde la ciudad donde la leyenda del 'Pied Piper de Hamelin' está en casa
FrankAT (Orgulloso de ser un Datanaut)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.