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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
11097486
Helper I
Helper I

Power Query: valor de la transacción anterior (otra fila)

Hola, me gustaría poder mostrar el valor de fecha y venta de la transacción anterior en Power Query M (no DAX). La transacción anterior está en otra fila. Gracias

11097486_1-1607695129097.png

4 REPLIES 4
mahoneypat
Employee
Employee

Esta es una manera de hacerlo en el editor de consultas. Para ver cómo funciona, simplemente cree una consulta en blanco, vaya a Editor avanzado y reemplace el texto allí con el código M a continuación.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kstV4jML8pW0lEy1DfUNzIwMgAxDZRidaKVfDMTczPBMsZwGVOwjI8jWNgEJmyErsEULmOMrMEcbo4hWBjFeguYpJlSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [City = _t, Date = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"City", type text}, {"Date", type date}, {"Sales", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Date", Order.Descending}}),
    #"Added Custom" = Table.AddColumn(#"Sorted Rows", "Custom", each let thisdate = [Date], thiscity = [City] in Table.FirstN(Table.SelectRows(#"Changed Type", each [Date] < thisdate and [City] = thiscity),1)),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Date", "Sales"}, {"Date.1", "Sales.1"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Custom",{{"Date.1", "Prev Date"}, {"Sales.1", "Prev Sales"}})
in
    #"Renamed Columns"

saludos

palmadita





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hola Pat, cerca pero no exactamente. Su solución me da la fecha mínima y no la fecha anterior. ¿Alguna idea? Gracias

11097486_0-1608051451012.png

11097486_1-1608051551021.png

11097486
Helper I
Helper I

Hola, no es realmente lo que estoy buscando. Necesito algo que pueda encontrar la fecha anterior de la misma categoría (en este caso ciudad). Gracias

v-yangliu-msft
Community Support
Community Support

Hola 11097486 ,

Aquí están los contenidos relevantes para que usted pueda comprobar y espera ayudarle:

https://community.powerbi.com/t5/Desktop/Power-Query-Use-Previous-Rows-Value-in-Current-Calculation/...

https://community.powerbi.com/t5/Desktop/Power-Query-M-to-Display-Correct-Start-Date-Script-Attached...

https://docs.microsoft.com/en-us/powerquery-m/quick-tour-of-the-power-query-m-formula-language

Saludos

Liu Yang

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.