Forum Discussion

admin11's avatar
admin11
Icon for Memorable Member rankMemorable Member
5 years ago
Solved

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))

 

https://www.dropbox.com/s/924vbx80zcy91ii/PBT%20GL%20VER0025%20How%20to%20get%20YTD%20using%20TOTALYTD%20command.pbix?dl=0

Above link is my PBI file

 

Paul

 

  • 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:

    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.

3 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion

    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")

     

    • admin11's avatar
      admin11
      Icon for Memorable Member rankMemorable Member

      Hi Allison

      Thank you for sharing.

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

       

  • v-robertq-msft's avatar
    v-robertq-msft
    Icon for Community Support rankCommunity 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:

    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.