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
admin11
Memorable Member
Memorable Member

Measure return correct value , but get syntax shown error sign , how to clear it ?

Hi All

 

Below measure working fine :-

_LYTD_REV =
var _max = date(year(today())-1,month(today()),day(today()))
return
TOTALYTD(('GL'[AMOUNT_REV]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)


I have decide to add one more condition to above measure , SOURCE=TS :-
_LYTD_REV TDS =
var _max = date(year(today())-1,month(today()),day(today()))
return
TOTALYTD(('GL'[AMOUNT_REV]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max,
FILTER( GL, [SOURCE] = "TS" ))
 
Above measure return correct result , but it shown error sign , see below image :-

admin11_0-1616884909555.png

May i know how to clear the error ?

 

Below my PBI file :-

https://www.dropbox.com/s/8fzg8stsqhqensy/PBT_V2021_392%20TI_SI_GL%20REV%20measure%20shown%20error%2...

Paul Yeo

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @admin11 

 

Have your problem been solved? I checked your file, It seems that the third parameter in TOTALYTD can only write one filter, and the second will become the fourth parameter by default, causing errors, but the actual calculation will be included.

You can easily use calculate to remove red error.

Like this:

 

_LYTD_REV TDS =
VAR _max =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
RETURN
    CALCULATE (
        TOTALYTD (
            ( 'GL'[AMOUNT_REV] ),
            DATEADD ( 'Date'[Date], -1, YEAR ),
            'Date'[Date] <= _max
        ),
        FILTER ( GL, [SOURCE] = "TS" )
    )

 

 

Best Regards

Janey Guo

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-janeyg-msft
Community Support
Community Support

Hi, @admin11 

 

Have your problem been solved? I checked your file, It seems that the third parameter in TOTALYTD can only write one filter, and the second will become the fourth parameter by default, causing errors, but the actual calculation will be included.

You can easily use calculate to remove red error.

Like this:

 

_LYTD_REV TDS =
VAR _max =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
RETURN
    CALCULATE (
        TOTALYTD (
            ( 'GL'[AMOUNT_REV] ),
            DATEADD ( 'Date'[Date], -1, YEAR ),
            'Date'[Date] <= _max
        ),
        FILTER ( GL, [SOURCE] = "TS" )
    )

 

 

Best Regards

Janey Guo

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

I'm not 100% sure but you can clean it up a little by removing the Filter function. This shouldn't be needed as the TOTALYTD function is already expecting a filter here. 

 

 

 

LYTD_REV TDS =
VAR _max =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
RETURN
    TOTALYTD (
        ( 'GL'[AMOUNT_REV] ),
        DATEADD ( 'Date'[Date], -1, YEAR ),
        'Date'[Date] <= _max,
        GL[SOURCE] = "TS"
    )

 

 

 

 

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.