Forum Discussion

jnpb's avatar
jnpb
Icon for Helper I rankHelper I
4 years ago
Solved

Issues generating a YTD from previous year

Hi everyone, 


I'm trying to generate a YTD from the previous year and am either using an incorrect syntax or just not going about this the correct way. Working with PBI is not normally my area of expertise so please bear with me: 

 

1. I have an NPS value that I get from a column in my import. This is manipulated by a Year slicer, and in this example it will remain in 2022 (current year). Data I'm working with is configured like this: 

 

The NPS metric is visualized on a clustered column chart and I need to add the NPS from the previous year, YTD next to each column to compare against. I have been looking around online and trying to form the correct measure syntax to accomplish this but so far haven't found anything that works (either the syntax is incorrect or it accepts the syntax but the visualization can't be displayed). 

 

Any assistance with composing this would be hugely appreciated, both so I can move past this in my project as well as so that I can learn how to approach this correctly in the future. 


Thanks!

 

 

  • Hi jnpb ,

     

    I think it should be because your date contains timestamp. You need to create a new Date column, like this. 

     

     

    Then change the measure to

     

    Measure = 
    CALCULATE (
        SUM ( 'Table'[NPSRecommend] ),
        SAMEPERIODLASTYEAR ( DATESYTD ( 'Table'[Date] ) )
    )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 Replies

    • jnpb's avatar
      jnpb
      Icon for Helper I rankHelper I

      Hi Nishant, 

      I tried to figure this out but my attempt doesn't work (I'm very unfamiliar with the subject matter). This is what I tried - can you help identify what I did wrong and how to correct it? 

       

      Measure = TOTALYTD(PREVIOUSYEAR(Query1[NPSRecommend]),Query1[Submission Date])
      • v-kkf-msft's avatar
        v-kkf-msft
        Icon for Community Support rankCommunity Support

        Hi jnpb ,

         

        Please try the measure.

         

        Measure = 
        CALCULATE (
            SUM ( 'Table'[NPSRecommend] ),
            SAMEPERIODLASTYEAR ( DATESYTD ( 'Table'[Submission Date] ) )
        )

         

        If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
        Best Regards,
        Winniz
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.