Forum Discussion

mohammadyousaf's avatar
mohammadyousaf
Resolver II
5 years ago
Solved

Calculate Sum using Filter

I am trying to calculate sum of specific rows in a table and using the following formula, it gives me an error of Too many arguments. 

 

Delivery = SUMX('Table1',FILTER('Table1','Table1'[Items]="Steel",[Quantity])) 
 
I want to filter column Items to steel and calcuate the total delivery. 

Can anybody help please. 
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi mohammadyousaf 

    There is something wrong in your sumx funtion. The code by sumx is in format as below.

    Code = SUMX(<table>, <expression>)

    So you add there are two tables in your code," Table1" and "FILTER(Table1)", both of them will return to tables.

    For reference: SUMX

    Update your code:

    Delivery = SUMX(FILTER('Table1','Table1'[Items]="Steel"),[Quantity])

    Best Regards,
    Rico Zhou

     

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

     

2 Replies

  • selimovd's avatar
    selimovd
    Most Valuable Professional

    Hey mohammadyousaf ,

     

    you cannot use SUMX like this. In general SUMX is an iterative function, this means an expression is executed row by row and then the row results will be summarized.

     

    I think you should go with CALCULATE:

     

    Delivery =
    CALCULATE(
        [Quantity],
        'Table1'[Items] = "Steel"
    )

     

     
    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis
     
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi mohammadyousaf 

    There is something wrong in your sumx funtion. The code by sumx is in format as below.

    Code = SUMX(<table>, <expression>)

    So you add there are two tables in your code," Table1" and "FILTER(Table1)", both of them will return to tables.

    For reference: SUMX

    Update your code:

    Delivery = SUMX(FILTER('Table1','Table1'[Items]="Steel"),[Quantity])

    Best Regards,
    Rico Zhou

     

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