Forum Discussion

rosefei's avatar
rosefei
Microsoft Employee
6 years ago

formula sum vs table sum

Hi all,

 

I have a rating table that have the following columns:

1) service

2) categoryID

3) subcategoryID

4) rating

5) target

6) BelowTarget = IF(rating<target, "Yes", "No)

7) BelowTargetDepth = if([Rating]<[TargetProfile],[TargetProfile]-[Rating],0)

 

And a meausre:

TargetIndex = SUM([BelowTargetDepth])*COUNT([SubCategoryID])

 

When I put a table together, the sum is different... how do I write the formula so that the sum on each row is the same as the bottom?

servicecategorytargetcount of rating (below target)sum of depthTargetIndex = count of rating * sum of depth
AC13212
AC13111
AC13122
AC13111
AC135525

sum at the table:                10                                              10                    100

 

You can tell the column TargetIndex does not add to 100... I am confused.. Thank you for your help!!

7 Replies

  • az38's avatar
    az38
    Community Champion

    hi rosefei 

    i could not to repeat your data model, but it looks like task for SUMX() function, like

    TargetIndex = SUMX('Table',CALCULATE(SUM([BelowTargetDepth]))*CALCULATE(COUNT([SubCategoryID])) )

     

    • rosefei's avatar
      rosefei
      Microsoft Employee

      Very interesting! I think we are close. Still have a small prob. 

       

      Now the targetIndex in each row is not doing the multiplication any more. I think this is because the underlying table is on subcategory level, the SUMX is only doing on row level sun, which means the count(subcategroyID) is always 1. 

       

      I tried a few different combination but still not getting the right answer...

  • Hi rosefei ,

     

    Looking at your description and your DAX, you seem to be using a measure that you have not defined "[TargetProfile]" - what is this calculation?

    • rosefei's avatar
      rosefei
      Microsoft Employee

      Target = TargetProfile. Sorry I typed the table and did not type the name right