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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Syndicate_Admin
Administrator
Administrator

Convertir columna acumulativa en columna incremental

Tengo un requisito donde el campo de fecha / hora y diferentes identificadores de origen y su valor acumulado. Quería encontrar por qué valor está aumentando cada fila.

9192gks_0-1628678663261.png

Quiero crear una columna "val incremental" como la anterior. Probé con una fórmula dax :

Val incremental =
VAR PrevDate = CALCULATE(ISFILTERED(MAX('pa_data pa_cnt_ihub_ethernetport'[start_time]),
ALL('pa_data pa_cnt_ihub_ethernetport'),
'pa_data pa_cnt_ihub_ethernetport'[start_time] < EARLIER('pa_data pa_cnt_ihub_ethernetport'[start_time]))
RETURN 'pa_data pa_cnt_ihub_ethernetport'[ifhc_in_multicast_pkts] - LOOKUPVALUE('pa_data pa_cnt_ihub_ethernetport'[ifhc_in_multicast_pkts], 'pa_data pa_cnt_ihub_ethernetport'[start_time], PrevDate))
2 ACCEPTED SOLUTIONS
Syndicate_Admin
Administrator
Administrator

@9192gks , crear una nueva columna como

Nueva columna =
var _max = maxx(filter(Table, [ID] = earlier([ID]) && [start_time] < earlier([start_time])),[start_time])
devolución
[val] - maxx(filter(Table, [ID] = earlier([ID]) && [start_time] =_max ),[val])

View solution in original post

Syndicate_Admin
Administrator
Administrator

No @9192gks,

Puede crear una columna de índice:

index =
VAR index =
    RANKX (
        FILTER ( ALL ( 'table' ), 'table'[ID] = EARLIER ( 'table'[ID] ) ),
        'table'[Start_time],
        ,
        ASC,
        DENSE
    )
RETURN
    index

A continuación, use el siguiente dax para crear una nueva columna:

VAR index =
    RANKX (
        FILTER ( ALL ( 'table' ), 'table'[ID] = EARLIER ( 'table'[ID] ) ),
        'table'[Start_time],
        ,
        ASC,
        DENSE
    )
RETURN
    index

Y si solo desea crear una sola columna en la tabla, use el siguiente dax:

New column = 
VAR _max =
    MAXX (
        FILTER (
            'table',
            [ID] = EARLIER ( [ID] )
                && [start_time] < EARLIER ( [start_time] )
        ),
        [start_time]
    )
RETURN
    IF (
        MAXX (
            FILTER ( 'table', [ID] = EARLIER ( [ID] ) && [start_time] = _max ),
            [val]
        )
            = BLANK (),
        BLANK (),
        [val]
            - MAXX (
                FILTER ( 'table', [ID] = EARLIER ( [ID] ) && [start_time] = _max ),
                [val]
            )
    )

vluwangmsft_0-1629191912909.png

Deseo que sea útil para usted!

Saludos

Lucien

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

No @9192gks,

Puede crear una columna de índice:

index =
VAR index =
    RANKX (
        FILTER ( ALL ( 'table' ), 'table'[ID] = EARLIER ( 'table'[ID] ) ),
        'table'[Start_time],
        ,
        ASC,
        DENSE
    )
RETURN
    index

A continuación, use el siguiente dax para crear una nueva columna:

VAR index =
    RANKX (
        FILTER ( ALL ( 'table' ), 'table'[ID] = EARLIER ( 'table'[ID] ) ),
        'table'[Start_time],
        ,
        ASC,
        DENSE
    )
RETURN
    index

Y si solo desea crear una sola columna en la tabla, use el siguiente dax:

New column = 
VAR _max =
    MAXX (
        FILTER (
            'table',
            [ID] = EARLIER ( [ID] )
                && [start_time] < EARLIER ( [start_time] )
        ),
        [start_time]
    )
RETURN
    IF (
        MAXX (
            FILTER ( 'table', [ID] = EARLIER ( [ID] ) && [start_time] = _max ),
            [val]
        )
            = BLANK (),
        BLANK (),
        [val]
            - MAXX (
                FILTER ( 'table', [ID] = EARLIER ( [ID] ) && [start_time] = _max ),
                [val]
            )
    )

vluwangmsft_0-1629191912909.png

Deseo que sea útil para usted!

Saludos

Lucien

Syndicate_Admin
Administrator
Administrator

@9192gks , crear una nueva columna como

Nueva columna =
var _max = maxx(filter(Table, [ID] = earlier([ID]) && [start_time] < earlier([start_time])),[start_time])
devolución
[val] - maxx(filter(Table, [ID] = earlier([ID]) && [start_time] =_max ),[val])

Excelente solución!! pero una cosa, ¿qué pasa con el valor inicial? Comienza con 35835 que creo que no es correcto

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors
Top Kudoed Authors