Forum Discussion

harirao's avatar
harirao
Post Prodigy
6 years ago

DAX: Difference Percentage(Current Week % - Previous Week%)

Hi All,

 

I want to calculated diffrence % of (Current week- Previous Week). created two new columns i.e Latest Date & Previous week.

 



9 Replies

  • harirao's avatar
    harirao
    Post Prodigy

    Below is the example what i am looking I want to create a new column where i should see the Diffrence %

    Product ID "142263-013" for Current wk diffrence is "-15%"(100%-115%) & "142263-013" -63%(100%-163%)

    Please note Forecastintegrity% is caluclated column

     

     

    Regards,

    Hari

    • parry2k's avatar
      parry2k
      Super User

      harirao did you referred to the videos I posted earlier, what exactly not working if you watched these videos.

    • v-kelly-msft's avatar
      v-kelly-msft
      Community Support

      Hi  harirao ,

       

      Go to query editor>add column>Index column:

       

       

      Then you can create a calculated column to achieve what you need:

       

      Column = 
      var a=CALCULATE(MAX('Table'[Forcastintergity%]),FILTER('Table','Table'[Index]<EARLIER('Table'[Index])&&'Table'[Product ID]=EARLIER('Table'[Product ID])))
      Return
      IF(a=BLANK(),BLANK(),'Table'[Forcastintergity%]-a)

       

      And you will see:

      Or you can create a measure instead:

       

      Measure = 
      var a=CALCULATE(MAX('Table'[Forcastintergity%]),FILTER(ALL('Table'),'Table'[Index]<SELECTEDVALUE('Table'[Index])&&'Table'[Product ID]=SELECTEDVALUE('Table'[Product ID])))
      Return
      IF(a=BLANK(),BLANK(),MAX('Table'[Forcastintergity%])-a)

       

      And you will see:

      For the related .pbix file,pls click here.

       

      Best Regards,
      Kelly
      Did I answer your question? Mark my post as a solution!

       

       

      • harirao's avatar
        harirao
        Post Prodigy

        Thanks for your solution,

        Please note: Forecastintegrity% is calculated measure, both solution is not working.

         

         

        Regards,

        Hari