Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

YTD DAX

Hi everyone, 

I'm making a Dax measure to calculate a YTD, my measure is : 

 YTD = TOTALYTD([Monthly TNQ],'Calendar'[Date])
So according to this measure, my results are right, but the data are existing from 1/1/2019 to 1/9/2019 so in my bar chart the data are shown until 1/12/2019. 
 
So I would like to change this measure in order to have the real results from 1/1/2019 to 1/9/2019.
 
Thank you.
Best regards.
  • Can you try like

    YTD = 
    var _max = max(table[date])
    TOTALYTD([Monthly TNQ],'Calendar'[Date],'Calendar'[Date]<=_max)
  • Mariusz's avatar
    Mariusz
    6 years ago

    Hi Anonymous 

     

    Try something like 

     

    Sales YTD = 
    IF( 
        NOT ISEMPTY( Sales ), 
        CALCULATE(
            [Sales],
            DATESYTD( 'Calendar'[Date] )
        )
    )
    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

     

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    this is the results on my bar chart graph : 

    • amitchandak's avatar
      amitchandak
      Super User

      Can you try like

      YTD = 
      var _max = max(table[date])
      TOTALYTD([Monthly TNQ],'Calendar'[Date],'Calendar'[Date]<=_max)
    • Mariusz's avatar
      Mariusz
      Community Champion

      Hi Anonymous 

       

      Try something like 

       

      Sales YTD = 
      IF( 
          NOT ISEMPTY( Sales ), 
          CALCULATE(
              [Sales],
              DATESYTD( 'Calendar'[Date] )
          )
      )
      Best Regards,
      Mariusz

      If this post helps, then please consider Accepting it as the solution.

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Mariusz 

        It does work and this is the results comparing Y vs Y-1 : 

         

        How can I get the results like is shown in this graph : 

         

        Thank you !

        Best regards.