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
charly_bron
Frequent Visitor

Help with DAX Mesure to relate to tables

Hello Friends, I have the following two tables. In one, there are the unique codes, dates, and values ​​for the period.

In the other, it is the fact table. I need the value corresponding to the period for each code to appear in that table.

Thank you so much!!


Table 1
Captura de pantalla 2023-04-03 223508.jpg

Table2

Captura de pantalla 2023-04-03 223536.jpg

 

Table Expected

Captura de pantalla 2023-04-03 223733.jpg

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Hola

En la Tabla 2, escriba esta fórmula de columna calculada

Valor = calcular(suma(Tabla1[Valor]),filtro(Tabla1,Tabla1[Código]=antes(Tabla2[Código])&&Tabla1[Fecha]=antes(Tabla2[Fecha])))

Espero que esto ayude.

Syndicate_Admin
Administrator
Administrator

@charly_bron ,

Puede crear una columna calculada como se muestra a continuación en 'Tabla 2' para obtenerla:

Column = 
CALCULATE (
    SUM ( 'Table 1'[Value] ),
    FILTER (
        'Table 1',
        'Table 1'[Period] = 'Table 2'[Period]
            && 'Table 1'[Code] = 'Table 2'[Code]
    )
)

vyiruanmsft_0-1680745641233.png

Además, también puede crear una medida como se muestra a continuación para obtenerla:

Measure = 
VAR _selperiod =
    SELECTEDVALUE ( 'Table 2'[Period] )
VAR _selcode =
    SELECTEDVALUE ( 'Table 2'[Code] )
RETURN
    CALCULATE (
        SUM ( 'Table 1'[Value] ),
        FILTER (
            'Table 1',
            'Table 1'[Period] = _selperiod
                && 'Table 1'[Code] = _selcode
        )
    )

vyiruanmsft_1-1680745714236.png

Saludos

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.