Forum Discussion

shanestocks's avatar
shanestocks
Icon for Helper I rankHelper I
2 years ago
Solved

Total Value not Summing Row Values?

Hi all. I have created an "aged stock analysis". One of the columns is "Production Quantity", which simply looks at the earliest date a batch existed, and tries to SUM the total quantity in KG (anoth...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi lbendlin ,thanks for the quick reply, I'll add more.

    Hi shanestocks ,

    It is recommended that you use the 'ISINSCOPE' function with the IF function

    ISINSCOPE function (DAX) - DAX | Microsoft Learn

    I assumed some simple data

    Regarding your question, the row totals are calculated based on how they are calculated in your measure.Suppose I need to get the maximum value, but in the row total I need to calculate the sum of the maximum values, this will happen.

     

    You need to store the maximum value in a virtual table you created, and then use the 'ISINSCOPE' function to perform calculations.

     

    Measure 2 = 
    VAR _table = SUMMARIZE('Table','Table'[Type],'Table'[group],"Value",[Measure])    //Create a virtual table to store values
    VAR _isParent = ISINSCOPE('Table'[group])
    VAR _group = SELECTEDVALUE('Table'[group])
    RETURN 
    IF(_isParent = FALSE(),
    SUMX(_table,[Value]),
    SUMX(FILTER(_table ,[group] = _group),[Value])
    )

     

     

    Best Regards,
    Wenbin Zhou