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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Nick2358
Helper III
Helper III

Calculated measure using other calculated measure

Hello everyone,

 

I have this measure that calculates YTD Actual (-2 months) + Budget of months left.

 

When I use the following with "Calculate(SUM))" everything works perfectly:

 

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)
return
CALCULATE(SUM('Conso Bdgt 2020'[Value]), FILTER(Dates, Dates[Date_2] <=_max && Dates[Date_2] >=-_min))
+ CALCULATE(SUM('Calculation_Conso Bdgt 2020'[Value]), FILTER(Dates, Dates[Date_2]<=_maxb && Dates[Date_2]>=_minb))
 
Now when I use the same measure but with other calculated measures instead of "Calculate(SUM))" it doesn't work, underlines the last 2 lines in red and says on the first line "Unexpected expression 'Fillter'" and on the second "Cannot find name '[YTD_Bdgt_GP_Before_Com]], FILTER(Dates, Dates[Date_2]'".
It also says the syntax for ',' is incorrect.
I tried different things but nothing worked. 
 
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
[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
 
Thanks in advance for your help,
 
NIck
1 ACCEPTED SOLUTION

@Nick2358,

 

Try this. Each measure needs a 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,

 

You need the CALCULATE function:

 

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 thanks a lot for your answer.

 

The function seems to work however it says now "A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

 

Any ideas what could cause this?

 

Thanks a lot for your helps,

 

Nick

@Nick2358,

 

Try this. Each measure needs a 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!




Hi @DataInsights ,

 

It worked,

 

Thanks a lot for your help,

 

Nick,

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors