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
Anonymous
Not applicable

Cambiar tabla de historial de fechas

Hola a todos

¿Alguien puede ver lo que hago mal aquí?

Usando este script y obtener la Columna PreviousWrong, pero lo recocido para ser como 'PreviousWant'

PreviousWrong á coalesce(maxx(filter(Table,Table[WorkItemId] á earlier(Table[WorkItemId]) && Table[ChangedDate] < earlier(Table[ChangedDate]) ),Table[ChangedDate]),Table[ChangedDate])

WorkItemIdBoardLocationSKChangedDatePreviousWrongAnteriorWant:-)
15088703414/08/202014/08/202014/08/2020
15088703414/08/202014/08/202014/08/2020
15090581820/08/202014/08/202014/08/2020
15090581820/08/202014/08/202020/08/2020
15090581820/08/202014/08/202020/08/2020
15090581820/08/202014/08/202020/08/2020
35088749614/08/202014/08/202014/08/2020
35088749614/08/202014/08/202014/08/2020
35090590720/08/202014/08/202014/08/2020
35090591121/08/202020/08/202020/08/2020
35090591121/08/202020/08/202021/08/2020
35090591121/08/202020/08/202021/08/2020
35090591121/08/202020/08/202021/08/2020
35090591127/08/202021/08/202021/08/2020
35090591127/08/202021/08/202027/08/2020
35090590731/08/202027/08/202027/08/2020
35090591101/09/202031/08/202031/08/2020
35090591101/09/202031/08/202001/09/2020
35090590708/09/202001/09/202001/09/2020
35090590708/09/202001/09/202008/09/2020
35090590708/09/202001/09/202008/09/2020
45090590820/08/202020/08/202020/08/2020
45090591121/08/202020/08/202020/08/2020
45090591121/08/202020/08/202021/08/2020
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hola @MartinLomborg ,

En primer lugar, agregue una columna de índice en Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("xdFBCsAgDATAv3gW3GisyVuk//9G9VAUxKKU0ltgYNkkORsy1kSIJAQuo4eHE0dsTruEiigkDT2+xHAXYj2GQgtYYhVpEluRqEP6AdMO9quEeSzUYU9bcFV5rdx0fCo/nWmO5wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [WorkItemId = _t, BoardLocationSK = _t, ChangedDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WorkItemId", Int64.Type}, {"BoardLocationSK", Int64.Type}, {"ChangedDate", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

A continuación, cree una medida como se indica a continuación:

Measure = 
VAR _index =
    MAX ( 'Table'[Index] )
VAR _cdate =
    CALCULATE (
        MAX ( 'Table'[ChangedDate] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[WorkItemId] = MAX ( 'Table'[WorkItemId] )
                && 'Table'[Index] < _index
        )
    )
RETURN
    IF ( ISBLANK ( _cdate ), MAX ( 'Table'[ChangedDate] ), _cdate )​

O puede actualizar la fórmula de la columna calculada "PreviousWrong" como se agrega a continuación después de agregar la columna de índice:

PreviousWrong = 
COALESCE (
    MAXX (
        FILTER (
            'Table',
            'Table'[WorkItemId] = EARLIER ( 'Table'[WorkItemId] )
                && 'Table'[Index] < EARLIER ( 'Table'[Index] )
        ),
        'Table'[ChangedDate]
    ),
    'Table'[ChangedDate]
)

Change date history table.JPG

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yiruan-msft
Community Support
Community Support

Hola @MartinLomborg ,

En primer lugar, agregue una columna de índice en Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("xdFBCsAgDATAv3gW3GisyVuk//9G9VAUxKKU0ltgYNkkORsy1kSIJAQuo4eHE0dsTruEiigkDT2+xHAXYj2GQgtYYhVpEluRqEP6AdMO9quEeSzUYU9bcFV5rdx0fCo/nWmO5wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [WorkItemId = _t, BoardLocationSK = _t, ChangedDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WorkItemId", Int64.Type}, {"BoardLocationSK", Int64.Type}, {"ChangedDate", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

A continuación, cree una medida como se indica a continuación:

Measure = 
VAR _index =
    MAX ( 'Table'[Index] )
VAR _cdate =
    CALCULATE (
        MAX ( 'Table'[ChangedDate] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[WorkItemId] = MAX ( 'Table'[WorkItemId] )
                && 'Table'[Index] < _index
        )
    )
RETURN
    IF ( ISBLANK ( _cdate ), MAX ( 'Table'[ChangedDate] ), _cdate )​

O puede actualizar la fórmula de la columna calculada "PreviousWrong" como se agrega a continuación después de agregar la columna de índice:

PreviousWrong = 
COALESCE (
    MAXX (
        FILTER (
            'Table',
            'Table'[WorkItemId] = EARLIER ( 'Table'[WorkItemId] )
                && 'Table'[Index] < EARLIER ( 'Table'[Index] )
        ),
        'Table'[ChangedDate]
    ),
    'Table'[ChangedDate]
)

Change date history table.JPG

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

@MartinLomborg Suponiendo que son columnas Date reales, esto debe ser:

Previous = 
    VAR __PreviousDate = MAXX(FILTER('Table (25)',[WorkItemID]=EARLIER([WorkItemID]) && [BoardLocation]<EARLIER([BoardLocation])),[ChangedDate])
    VAR __Count = COUNTX(FILTER('Table (25)',[WorkItemID]=EARLIER([WorkItemID]) && [BoardLocation]<EARLIER([BoardLocation])),[Risk ID])
RETURN
    IF(__Count<0 || ISBLANK(__PreviousDate),[ChangedDate],__PreviousDate)

Por lo tanto, si eso no funciona sospecho que son columnas de texto y no fecha, sólo una corazonada.

Vea mi artículo sobre el tiempo medio entre fallas (MTBF) que utiliza ANTES: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
El patrón básico es:
Columna ?
VAR __Current á [Valor]
VAR __PreviousDate á MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

VAR __Previous á MAXX(FILTER('Table',[Fecha]-__PreviousDate),[Valor])
devolución
__Current - __Previous


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Gracias Greg

En el script veo [ID de riesgo] que no reconozco?

Salud

Martin

amitchandak
Super User
Super User

@MartinLomborg , creo que necesita agregar BoardLocationSK en el filtro

PreviousWrong á coalesce(maxx(filter(Table,Table[WorkItemId] á earlier(Table[WorkItemId]) && [BoardLocationSK] á earlier(Table[BoardLocationSK])
Tabla[ChangedDate] < earlier(Table[ChangedDate]) ),Table[ChangedDate]),Table[ChangedDate])

Anonymous
Not applicable

Gracias Amitchandak por tomarse su tiempo.

Al agregar Boardlocation, obtengo el mismo valor que el ChangeDate original?

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.