Forum Discussion

TravisGlanzer's avatar
TravisGlanzer
Frequent Visitor
5 years ago
Solved

SumX Total

I finally figured out a DAX to calculate the product of two attributes without creating a table:

 

That produces the third column below which looks great.  The total row is off though as it is following the same logic.  

If I add up the third column the true total should be 148,724, not 213,618.  I really do not use the total and can hide it.  The problem is that I am trying to create a formula for the 4th column that is the correct sum of all items in the 3rd column.  

 

I am using the following formula which is not working:  

 

WeightedCollStaffProcTotal = CALCULATE([WeightedCollStaffProc],All(BRG_PHLEBOTOMY_GROUP[Phlebotomy_Group]))

 

Suggestions?

 

  • jameszhang0805's avatar
    jameszhang0805
    5 years ago

    Let me give you an example:

    In the above picture :

    SalesQty V1 = SUM( Sales[Quantity] )   
    SalesQty V2 = [SalesQty V1] +1000
    you can see the total number of SalesQty V2 is incorrect.  Because in the total line there is no filter.
    So the calculation logic of the total number is to calculate all category sales quantity +1000, 140180+1000. But that's not your expectation. Your expectation is to SUM all the values in the Sales Qty V2 column in the matrix. At this time you need to do like the below picture to get the correct result.

     

3 Replies

  • Hi, please try to use this method: Use SUMX+VALUES to wrap your Return.
    SUMX(VALUES( the column of current row contents in your matrix ), Return Result)

     
    • TravisGlanzer's avatar
      TravisGlanzer
      Frequent Visitor

      Appreciate your response.  Feel very ignorant here as I am not quite sure what you mean.  Do you mean:

       

      Sumx(Values(PhlebAttemptsper,Weightingper))

       

      It keeps wanting a table.  Or are you suggesting in the next metric, "WeightedCollStaffProcTotal" to create the sumx?  I keep getting the request for a table name???

       

      • jameszhang0805's avatar
        jameszhang0805
        Resolver IV

        Let me give you an example:

        In the above picture :

        SalesQty V1 = SUM( Sales[Quantity] )   
        SalesQty V2 = [SalesQty V1] +1000
        you can see the total number of SalesQty V2 is incorrect.  Because in the total line there is no filter.
        So the calculation logic of the total number is to calculate all category sales quantity +1000, 140180+1000. But that's not your expectation. Your expectation is to SUM all the values in the Sales Qty V2 column in the matrix. At this time you need to do like the below picture to get the correct result.