Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Measure not summing correctly for Total Row

Hi All,

 

This is driving me crazy. I reffered to this post by Greg_Deckler. Created YTD measure for Project Profit column present in Loss Factor table. Created 2 separate measures Profit and Loss with below calculation:

Project Profit =
CALCULATE(TOTALYTD(SUMX('Loss Factor', 'Loss Factor'[Project Profit] * [Budget Rate]), 'Calendar'[Date], ALL('Calendar')))
Profit = CALCULATE(IF([Project Profit] > 0, [Project Profit] , 0))
Loss = CALCULATE(IF([Project Profit] < 0, [Project Profit], 0 ))
Now when i'm dragging them in table visual the Profit is showing same value as Project Profit which is what it is doing as per calcualtion and being evaluated in current context but i'm expecting it to give different result like individual values summed up by project as shown in below screenshot, want to change the context tried ALL, ALLEXCEPT but no luck.
 

6 Replies

  • Please try

    Profit = CALCULATE(sum([Project Profit]) ,[Project Profit] > 0)
    Loss = CALCULATE(sum([Project Profit]) ,[Project Profit] < 0)
    
    OR
    
    Profit = CALCULATE(([Project Profit]) ,[Project Profit] > 0)
    Loss = CALCULATE(([Project Profit]) ,[Project Profit] < 0)

    Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
    Thanks.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak  sorry but you cannot use true/false condition inside calculate. Also we can not sum measure explicitly.  The below dax by TomMartens  was quite close but still not giving the expected result. 

      MeasureProfitFinal = 
      CALCULATE( 
          SUMX(
              ADDCOLUMNS(
              SUMMARIZE('AllData'
                  ,'AllData'[Client]
                  ,'AllData'[Date].[Month]
                  ,'AllData'[Retainer]
              )
              ,"This",[MeasureProfit])
              ,[This])
          )

       Please help me as this is bit urgent and not able to proceed further. When i export the data to the excel i get the correct result but not in Total row in table visual.

      • amitchandak's avatar
        amitchandak
        Icon for Super User rankSuper User

        Ok, profit is a calculated measure 

        try this, something like

         

        Sales GT 0 = CALCULATE(sum(Sales[Sales Amount]),filter(sales,Sales[Current Sales]>0))
        or
        
        Sales GT 0 = CALCULATE((Sales[Sales Amount]),filter(sales,Sales[Current Sales]>0))