Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Issues using FILTER in combination with SUM

I am trying to make a custom measure. What I want is to:

 

  1. Filter out some rows from an existing table.
  2. Then from the filtered table select a certain column.
  3. Then square all values in the column.
  4. Then sum all values in the column.

 

I thought I could use a FILTER to do this but that won't work. I am getting an error telling me the syntax for the SUM function is incorrect (have not even squared the number yet).

 

SUM(FILTER(MyTable, MyTable[class] = "1")[columnToSelect])

1 ACCEPTED SOLUTION

Hi @Anonymous !

Create a new column using following DAX to have Sqr. values of your column;

 

SqrtColumn = SQRT(Table[Column])

 

Now you can use this new column in your DAX measure formula;

 

Class = CALCULATE(SUM(Table[SqrtColumn]), FILTER(Table, Table[Class] = "1"))

 

Regards,

Hasham

View solution in original post

3 REPLIES 3
HashamNiaz
Solution Sage
Solution Sage

Hi @Anonymous !

You can use following DAX coede;

 

Class = CALCULATE(SUM(Table[Column]), FILTER(Table, Table[Class] = "1"))

 

Table is your table name & column is your column you want to sum.

 

Regards,

Hasham

Anonymous
Not applicable

How would one square all values before summing them?

Hi @Anonymous !

Create a new column using following DAX to have Sqr. values of your column;

 

SqrtColumn = SQRT(Table[Column])

 

Now you can use this new column in your DAX measure formula;

 

Class = CALCULATE(SUM(Table[SqrtColumn]), FILTER(Table, Table[Class] = "1"))

 

Regards,

Hasham

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.