Skip to main content
cancel
Showing results for 
Search instead 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

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors