Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
5 years ago
Solved

Add total to each record by category

Good morning!

I'm trying to add a column in a table to show the summation of a value by category. I've managed to get the result but he always adds it to me as a "summary." What I would like would be for the value "TotalxCategory" to be the numeric value only and to add it in each record. I add image because an image is worth a thousand words 😛

captura.png

Any idea how I can do it?

Thank you very much in advance.

  • Don'@Syndicate_Admin,

    You can also try measuring how to:

    TOTALCategory =
    
    CALCULATE(
    
    SUM('Table'[Value]),
    
    FILTER(
    
    ALL('Table'),
    
    'Table'[Category]=MAX('Table'[Category])
    
    )
    
    )

    Here's the output:

    v-xulin-mstf_0-1611812483380.png

    Here's the demo, please try it out: Add the total to each record by category

    Best regards

    Link

    If this post helps, please consider Accepting it as the solution to help the other members find it more quickly.

4 Replies

  • v-xulin-mstf's avatar
    v-xulin-mstf
    Icon for Community Support rankCommunity Support

    Don'@Syndicate_Admin,

    You can also try measuring how to:

    TOTALCategory =
    
    CALCULATE(
    
    SUM('Table'[Value]),
    
    FILTER(
    
    ALL('Table'),
    
    'Table'[Category]=MAX('Table'[Category])
    
    )
    
    )

    Here's the output:

    v-xulin-mstf_0-1611812483380.png

    Here's the demo, please try it out: Add the total to each record by category

    Best regards

    Link

    If this post helps, please consider Accepting it as the solution to help the other members find it more quickly.

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion

    JoelCami 

    Syndicate_Admin 

    You can do this using DAX filters, for example try a new Measure:

     

    TotalxCategoria =

    VAR _Cat = SELECTEDVALUE(Table[Categoria])

    RETURN
     SUMX(FILTER(Table, Table[Categoria] = _Cat), Table[Valor]) 

    • Syndicate_Admin's avatar
      Syndicate_Admin
      Icon for Administrator rankAdministrator

      Thank you very much for your response.

      This solution does not just work as it adds up the total of each value. For example in field A sum A - 20 and A -100