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
Syndicate_Admin
Administrator
Administrator

Intentar calcular el primer y el último valor en los registros de una categoría

Hola

Tengo una sola mesa que se ve así.

Categoría | | DateTime Valor

Un | 29/11/2021 22:21:24 | US$ 48

Un | 30/11/2021 10:15:56 | US$ 52

Un | 30/11/2021 16:24:32 | US$ 90

B | 28/11/2021 09:08:43 | US$ 16

B | 29/11/2021 11:25:54 | US$ 18

B | 29/11/2021 12:26:21 | US$ 29

B | 29/11/2021 13:42:28 | US$ 82

Estoy tratando de encontrar una fórmula DAX que calcule tanto el primer como el último valor tanto para A como para B, de modo que ofrezca algo que se vea así:

Categoría | | FirstValue ÚltimoValor

Un | US$ 48 | US$ 90

B | US$ 16 | US$ 82

He probado muchas opciones pero ninguna me da lo que necesito.

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

@Etienne123

Cree dos medidas de la siguiente manera:

FirstValue = FIRSTNONBLANK(Table1[ Value] , MAX(Table1[ DateTime ] ))
LastValue = LASTNONBLANK(Table1[ Value] , MAX(Table1[ DateTime ] ))


Agréguelos en una matriz

Fowmy_0-1638275513860.png



View solution in original post

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

@Etienne123 ,

Puede utilizar la siguiente fórmula para crear una nueva tabla:

NewTable = 
ADDCOLUMNS (
    VALUES ( 'Table'[Category] ),
    "FirstValue",
        VAR _firstdate =
            MINX ( FILTER ( 'Table', [Category] = EARLIER ( [Category] ) ), [DateTime] )
        RETURN
            LOOKUPVALUE ( 'Table'[Value], [Category], [Category], [DateTime], _firstdate ),
    "LatestValue",
        VAR _lastdate =
            MAXX ( FILTER ( 'Table', [Category] = EARLIER ( [Category] ) ), [DateTime] )
        RETURN
            LOOKUPVALUE ( 'Table'[Value], [Category], [Category], [DateTime], _lastdate )
)

Salida:

Eyelyn9_0-1638518183485.png

Saludos
Eyelyn Qin
Si esta publicación ayuda,entonces considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

Syndicate_Admin
Administrator
Administrator

@Etienne123

Cree dos medidas de la siguiente manera:

FirstValue = FIRSTNONBLANK(Table1[ Value] , MAX(Table1[ DateTime ] ))
LastValue = LASTNONBLANK(Table1[ Value] , MAX(Table1[ DateTime ] ))


Agréguelos en una matriz

Fowmy_0-1638275513860.png



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.