Forum Discussion

ARob198's avatar
ARob198
Helper IV
6 years ago
Solved

Filter sum by another table

I have a problem that seems like it should be easy, but I can't seem to get the formula right. 

 

I have two tables.  One has values by asset by date, the second defines the type of asset.  I need to create a measure or calculated column which sums the value by date and by type to use the values for additional analysis.  The tables are related by Name.  I am not sure how to filter the sum of the values by the Type.

 

Thank you very much.

 

Example:

Table 1  
DateNameValue
1/31/2016AB10
2/29/2016AB11
3/31/2016AB12
1/31/2016AA3
2/29/2016AA4
3/31/2016AA5
1/31/2016AC2.5
2/29/2016AC3.5
3/31/2016AC4.5

 

Table 2 
NameType
ABCash
AAStock
ACCash

 

Desired Result  
DateNameValue
1/31/2016Cash12.5
2/29/2016AB14.5
3/31/2016AB16.5
  • hi  ARob198 

    Do you mean that you do a filter in visual level filter and then use the measure result in another Measure?

    If so, you need to add the same filter into that visual too, the measure result in based on it row context and filter context.

     

    otherwise, you could define it in the measure like this

    Measure =CALCULATE( SUM('Table 1'[Value]),'Table 2'[Type]="Cash")
    

    But this will not interaction by slicer.

     

    Regards,

    Lin

9 Replies

    • ARob198's avatar
      ARob198
      Helper IV

      Hello ,  I apologzie but this isn't what I need.  Or maybe I don't understand how it can be used to solve the issue.  Perhaps I am not explaining this correctly.  The tables are already related.  I need to use the filtered value as an input in another calculation- I do not want to see it in a table- so it cannot just be a sum using a filter in a visual.  I need the cash value as an input for other calculations.  What is the formula for a sum that is filtered by a criteria in another table?  Just using Sum(value) does not give me a filtered value to use in another calculation.

       

      Thank you

      • Anonymous's avatar
        Anonymous
        Not applicable

        ARob198 Your desired result is wrong because the solution provided matches that criteria. Please re-evaluate what your desired result is.

    • ARob198's avatar
      ARob198
      Helper IV
      I am not really sure what you mean. I am trying the formula below. I am not getting an error, but the end result is blank. What do you suggest? Thank you for your help.
       
      Calculate(SUM('Table1'[VALUE]), filter(ALL(Table2), (Table2[TYPE] = "Cash"&& 'Table1'[NAME DETAIL] = 'Table2'[NAME])))