Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Sum value based on another column

Hi All,

 

I have two tables (Table 1, Table 2). In my Table 2, how can I create a column that shows the correct value if the Brand in Table 1 and Table 2 are the same?

 

 

 

Thanks,

Bee Kee

  • v-yingjl's avatar
    v-yingjl
    5 years ago

    Hi Anonymous ,

    Based on your description, you can create this calculated column in table 2:

    Value =
    CALCULATE (
        SUM ( 'Table 1'[Value] ),
        FILTER ( ALL ( 'Table 1' ), 'Table 1'[Brand] = EARLIER ( 'Table 2'[Brand] ) )
    )
    

    Attached a sample file in the below, hopes to help you.

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Community Champion

    Can you give more context and detail on what this relates to? There are many ways to get what you want, but should try to consider the best ways and avoid incorrect relationships (such as many to many). 

     

    Do you have a Brand Dimension or Lookup table that connects these two tables? 

     

    Do you know if you wan the calculation as a column or measure?

    Your screenshot is in Excel, are you using PowerPivot for DAX or what is the situation?

  • Hi,

    In Table2, why does J01 appear thrice?  Why does BR1 appear twice?  Give a good explanation.

    • Anonymous's avatar
      Anonymous
      Not applicable

      HI Ashish, sorry for the confusion. The reason of why it appeared multiple times is because of the different Period. 

       

      Regards,

      Bee Kee

      • v-yingjl's avatar
        v-yingjl
        Community Support

        Hi Anonymous ,

        Based on your description, you can create this calculated column in table 2:

        Value =
        CALCULATE (
            SUM ( 'Table 1'[Value] ),
            FILTER ( ALL ( 'Table 1' ), 'Table 1'[Brand] = EARLIER ( 'Table 2'[Brand] ) )
        )
        

        Attached a sample file in the below, hopes to help you.

         

        Best Regards,
        Community Support Team _ Yingjie Li
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.