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
Nick2358
Helper III
Helper III

Medida calculada utilizando otra medida calculada

Hola a todos,

Tengo esta medida que calcula YTD Real (-2 meses) + Presupuesto de meses restantes.

Cuando utilizo lo siguiente con "Calcular (SUM))" todo funciona perfectamente:

Act + Bdgt ?
var _max1 á MAXX(ALLSELECTED(Dates),Dates[Date_2])
var _max á EOMONTH(DATE(YEAR(_max1), MONTH(_max1)-2.1),0)
var _min - DATE(YEAR(_max1),1,1)
var _minb - DATE(YEAR(_max1), MONTH(_max1)-2,1)
var _maxb - DATE(YEAR(_max1), 12,31)
devolución
CALCULATE(SUM('Conso Bdgt 2020'[Valor]), FILTER(Dates, Dates[Date_2] <-_max && Dates[Date_2] >-_min))
+ CALCULATE(SUM('Calculation_Conso Bdgt 2020'[Valor]), FILTER(Dates, Dates[Date_2]<-_maxb && Dates[Date_2]>-_minb))
Ahora cuando uso la misma medida pero con otras medidas calculadas en lugar de "Calcular (SUM))" no funciona, subraya las últimas 2 líneas en rojo y dice en la primera línea "Expresión inesperada 'Fillter'" y en la segunda "No se puede encontrar el nombre '[YTD_Bdgt_GP_Before_Com]], FILTER(Dates, Dates[Date_2]'".
También dice que la sintaxis de ',' es incorrecta.
Intenté cosas diferentes, pero nada funcionó.
Acto + Bdgt_GP_Bef_Com ?
var _max1 á MAXX(ALLSELECTED(Dates),Dates[Date_2])
var _max á EOMONTH(DATE(YEAR(_max1), MONTH(_max1)-2.1),0)
var _min - DATE(YEAR(_max1),1,1)
var _minb - DATE(YEAR(_max1), MONTH(_max1)-2,1)
var _maxb - DATE(YEAR(_max1), 12,31)
devolución
[YTD_GP_Before_Com], FILTER(Dates, Dates[Date_2] <-_max && Dates[Date_2] >-_min)
+ [YTD_Bdgt_GP_Before_Com]], FILTER(Dates, Dates[Date_2]<-_maxb && Dates[Date_2]>-_minb
Gracias de antemano por su ayuda,
Nick
1 ACCEPTED SOLUTION

@Nick2358,

Prueba esto. Cada medida necesita un CALCULATE.

Act + Bdgt_GP_Bef_Com =
VAR _max1 =
    MAXX ( ALLSELECTED ( Dates ), Dates[Date_2] )
VAR _max =
    EOMONTH ( DATE ( YEAR ( _max1 ), MONTH ( _max1 ) - 2, 1 ), 0 )
VAR _min =
    DATE ( YEAR ( _max1 ), 1, 1 )
VAR _minb =
    DATE ( YEAR ( _max1 ), MONTH ( _max1 ) - 2, 1 )
VAR _maxb =
    DATE ( YEAR ( _max1 ), 12, 31 )
RETURN
    CALCULATE (
        [YTD_GP_Before_Com],
        FILTER ( Dates, Dates[Date_2] <= _max && Dates[Date_2] >= - _min )
    )
        + CALCULATE (
            [YTD_Bdgt_GP_Before_Com], FILTER(Dates, Dates[Date_2] <= _maxb
                && Dates[Date_2] >= _minb
        )





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
DataInsights
Super User
Super User

@Nick2358,

Necesita la función CALCULATE:

Act + Bdgt_GP_Bef_Com =
VAR _max1 =
    MAXX ( ALLSELECTED ( Dates ), Dates[Date_2] )
VAR _max =
    EOMONTH ( DATE ( YEAR ( _max1 ), MONTH ( _max1 ) - 2, 1 ), 0 )
VAR _min =
    DATE ( YEAR ( _max1 ), 1, 1 )
VAR _minb =
    DATE ( YEAR ( _max1 ), MONTH ( _max1 ) - 2, 1 )
VAR _maxb =
    DATE ( YEAR ( _max1 ), 12, 31 )
RETURN
    CALCULATE (
        [YTD_GP_Before_Com],
        FILTER ( Dates, Dates[Date_2] <= _max && Dates[Date_2] >= - _min ) + [YTD_Bdgt_GP_Before_Com]], FILTER(Dates, Dates[Date_2] <= _maxb
            && Dates[Date_2] >= _minb
    )





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@DataInsights muchas gracias por tu respuesta.

La función parece funcionar sin embargo, dice que ahora "Una función 'FILTER' se ha utilizado en una expresión True/False que se utiliza como una expresión de filtro de tabla. Esto no está permitido."

¿Alguna idea de lo que podría causar esto?

Muchas gracias por tu ayuda,

Nick

@Nick2358,

Prueba esto. Cada medida necesita un CALCULATE.

Act + Bdgt_GP_Bef_Com =
VAR _max1 =
    MAXX ( ALLSELECTED ( Dates ), Dates[Date_2] )
VAR _max =
    EOMONTH ( DATE ( YEAR ( _max1 ), MONTH ( _max1 ) - 2, 1 ), 0 )
VAR _min =
    DATE ( YEAR ( _max1 ), 1, 1 )
VAR _minb =
    DATE ( YEAR ( _max1 ), MONTH ( _max1 ) - 2, 1 )
VAR _maxb =
    DATE ( YEAR ( _max1 ), 12, 31 )
RETURN
    CALCULATE (
        [YTD_GP_Before_Com],
        FILTER ( Dates, Dates[Date_2] <= _max && Dates[Date_2] >= - _min )
    )
        + CALCULATE (
            [YTD_Bdgt_GP_Before_Com], FILTER(Dates, Dates[Date_2] <= _maxb
                && Dates[Date_2] >= _minb
        )





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hola @DataInsights ,

Funcionó

Muchas gracias por tu ayuda,

Nick

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.