Forum Discussion

leudyston's avatar
leudyston
Helper I
8 years ago
Solved

Remove Negative Values ​​with Calculate

Hello friends, I need to create a measure that can only bring the positive values ​​of an expression and that the total of this measure is also calculated only by adding the positive values, I have tried in every way to use the CALCULATE and the possible filters but I did not succeed .
In the attached image I did a demonstration of how the correct form of the values ​​would appear, I did this with the IF, which unfortunately does not bring the correct TOTAL value.

I am also attaching the link so they can download the .pbix file.

I await solutions, thank you !!

 

file .pbix

 

  • Hi,

     

    Try this revised measure

     

    =if(HASONEVALUE(ditens[Tamanho]),IF([Calc Sugestão de Compras]>=0,[Calc Sugestão de Compras],0),SUMX(SUMMARIZE(VALUES(ditens[Tamanho]),[Tamanho],"ABCD",IF([Calc Sugestão de Compras]>=0,[Calc Sugestão de Compras],0)),[ABCD]))

     

    Hope this helps.

     

9 Replies

  • Hi,

     

    I'd like to help but the file size is very large.  Trim the file to a couple of MB's and then share the download link.

    • leudyston's avatar
      leudyston
      Helper I

      Hello Ashish_Mathur, thank you for helping me with this question.

       

      I decrease the file size to 5Mb, the Stock Balance values ​​will not be the actual values, but what matters is how much I need to calculate correctly.

       

      File .pbix

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

         

        Try this revised measure

         

        =if(HASONEVALUE(ditens[Tamanho]),IF([Calc Sugestão de Compras]>=0,[Calc Sugestão de Compras],0),SUMX(SUMMARIZE(VALUES(ditens[Tamanho]),[Tamanho],"ABCD",IF([Calc Sugestão de Compras]>=0,[Calc Sugestão de Compras],0)),[ABCD]))

         

        Hope this helps.