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

My GL YTD measure return wrong result how to make it correct ?

Hi All

I have below measure which is working :-

_LYTD EXP = CALCULATE([AMOUNT],GL[1_EXP]="EXP",DATESBETWEEN('Date'[Date],date(year(today())-1,1,1),eomonth(today(),-13)+1))
it return correct amount = 910 693.85
 
i try to convert the above measure to more structure way , so that i can modify to LYTD :-
_LYTD_EXP =
var _max = date(year(today())-1,month(today()),day(today()))
return
TOTALYTD(('GL'[AMOUNT_EXP]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)
 
But it return wrong value , can some one share with me why ? and how to make it return 910 693.85
Paul
 


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

Hi @admin11  ,

I think I know what the problem is. 

the before measure:

_LYTD EXP =
CALCULATE (
    [AMOUNT],
    GL[1_EXP] = "EXP",
    DATESBETWEEN (
        'Date'[Date],
        DATE ( YEAR ( TODAY () ) - 1, 1, 1 ),
        EOMONTH ( TODAY (), -13 ) + 1
    )
)

Just as below,when i use the date mesuare,I get  the date calculate is 2020/1/1 to 2020/4/1

v-luwang-msft_0-1618558217315.pngv-luwang-msft_1-1618558237403.png

 

And when  I tried another measure, I get the date is to 2020/4/16 not 2020/4/1 ,due to this ,the two measure is different .

 

v-luwang-msft_2-1618558352045.png

 

 

You also could use the following measure ,

_LYTD_EXP =
VAR _max =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), 1 )
RETURN
    TOTALYTD (
        ( 'GL'[AMOUNT_EXP] ),
        DATEADD ( 'Date'[Date], -1, YEAR ),
        'Date'[Date] <= _max
    )

Final you will get the same value:

v-luwang-msft_3-1618558483857.png

 

 

Wish it is helpful for you!

 

Best Regards

Lucien

View solution in original post

5 REPLIES 5
v-luwang-msft
Community Support
Community Support

Hi @admin11  ,

I think I know what the problem is. 

the before measure:

_LYTD EXP =
CALCULATE (
    [AMOUNT],
    GL[1_EXP] = "EXP",
    DATESBETWEEN (
        'Date'[Date],
        DATE ( YEAR ( TODAY () ) - 1, 1, 1 ),
        EOMONTH ( TODAY (), -13 ) + 1
    )
)

Just as below,when i use the date mesuare,I get  the date calculate is 2020/1/1 to 2020/4/1

v-luwang-msft_0-1618558217315.pngv-luwang-msft_1-1618558237403.png

 

And when  I tried another measure, I get the date is to 2020/4/16 not 2020/4/1 ,due to this ,the two measure is different .

 

v-luwang-msft_2-1618558352045.png

 

 

You also could use the following measure ,

_LYTD_EXP =
VAR _max =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), 1 )
RETURN
    TOTALYTD (
        ( 'GL'[AMOUNT_EXP] ),
        DATEADD ( 'Date'[Date], -1, YEAR ),
        'Date'[Date] <= _max
    )

Final you will get the same value:

v-luwang-msft_3-1618558483857.png

 

 

Wish it is helpful for you!

 

Best Regards

Lucien

@v-luwang-msft Thank you for your sharing

v-luwang-msft
Community Support
Community Support

Hi @admin11 , 

When I click your link ,but  could not download your pbix ,could you pls share your file again?

 

Best Regards

Lucien

@v-luwang-msft 

Thank yo for look at my post , below is my PBI file :-

https://www.dropbox.com/s/qfb7nkqqqhxm0kx/PBT_V2021_397%20GL_TS%20SAMPLE.pbix?dl=0

 

Paul

amitchandak
Super User
Super User

@admin11 , The max date in dates between is 1-april-2021

 

Try this in LYTD

_LYTD_EXP = 

var _max = EOMONTH(date(year(today())-1,month(today()),day(today())),-1)+1
// Rest is same

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.