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

How to use TOTALYTD command for compute YTD ?

Hi All

My expression get error :-

_YTD_REV_ =

var _max = today()

return

calculate(TOTALYTD((GL[1_REV] = "REV"),'Date'[Date]),filter('Date','Date'[Date]<=_max))

 

admin11_0-1612229612956.png

https://www.dropbox.com/s/924vbx80zcy91ii/PBT%20GL%20VER0025%20How%20to%20get%20YTD%20using%20TOTALY...

Above link is my PBI file

 

Paul

 

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

Hi, @admin11 

According to your DAX formula, I think that the true reason for this error is that you should use a measure or an expression as the first parameter of the TOTALYTD() function, you can try to use this measure:

_YTD_REV_ =

var _max = today()

return

calculate(TOTALYTD([AMOUNT],'Date'[Date]),GL[1_REV] = "REV",filter('Date','Date'[Date]<=_max))

Then you can get the same value as the first measure you created, like this:

v-robertq-msft_0-1612320932613.png

You can download my test pbix file here

 

More info about TOTALYTD() function

 

Best Regards,

Community Support Team _Robert Qin

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

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @admin11 

According to your DAX formula, I think that the true reason for this error is that you should use a measure or an expression as the first parameter of the TOTALYTD() function, you can try to use this measure:

_YTD_REV_ =

var _max = today()

return

calculate(TOTALYTD([AMOUNT],'Date'[Date]),GL[1_REV] = "REV",filter('Date','Date'[Date]<=_max))

Then you can get the same value as the first measure you created, like this:

v-robertq-msft_0-1612320932613.png

You can download my test pbix file here

 

More info about TOTALYTD() function

 

Best Regards,

Community Support Team _Robert Qin

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

AllisonKennedy
Super User
Super User

@admin11  Do you have a measure you're trying to calculate as YTD? 

 

There's no problem using the DATESYTD as you have, but you need only a MEASURE as the first input parameter/argument in TOTALYTD and you are using a boolean expression. 

 

Try: 

 

_YTD_REV_ =

TOTALYTD([Amount],'Date'[Date]),GL[1_REV] = "REV")

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi Allison

Thank you for sharing.

I get error msg , i try to use 'G:[] also cannot.

admin11_0-1612235146216.png

 

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.