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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
saranee
Helper I
Helper I

Sum used in expression for sumx

Hi,

 

We have a dax function Sumx(Table,sum(SALARY)) We are getting like sum of salary for individual country for each row and then multiplied by each times the country appeared in the table.For e.g for UK ,Salary (20+30)*2=100 and getting that as an individual row.I am not getting what exactly is happening in this calculation

 

 

SUMX.PNGSUMX_RESULT.png

 

 

 

 

 

 

 

 

 

 

 

 

 

But when we are using dax function Sumx(Table,calculate(sum(SALARY))) then we are getting simple sum grouped by distinct country like below.Please can anyone help me with this.

 

SUMX_RESULT1.png

 

Thanks,

Saranee

1 ACCEPTED SOLUTION

Hi @saranee

 

This is one of the features of CALCULATE.. it transforms ROW CONTEXT into FILTER CONTEXT

 

To test it....just add these two simple calculated columns in your above TABLE... Both will give different results

 

Column1 =sum('Table'[Salary])
Column2=CALCULATE(sum('Table'[Salary]))

 

CONTEXT transformation.png

Simialry...inside an ITERATOR.... these two expressions behave differently

 


Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

Hi @saranee

 

Actually SUMX is an iterator. Iterators provide ROW context but not the filter context.....

 

So it behaves like a calculated column....i.e when you write SUM(Column) in a calculated column ...it sums the entire Table without taking into account filters like Row Filters, Column Filters, Slicers.

 

But when you wrap it inside CALCULATE... this ROW context is transformed into FILTER context


Regards
Zubair

Please try my custom visuals

Thanks Zubair for explanation but when I am using Calculate I am not using any filter in it,Sorry I am not having much idea about dax.

Thanks,

Saranee

Hi @saranee

 

This is one of the features of CALCULATE.. it transforms ROW CONTEXT into FILTER CONTEXT

 

To test it....just add these two simple calculated columns in your above TABLE... Both will give different results

 

Column1 =sum('Table'[Salary])
Column2=CALCULATE(sum('Table'[Salary]))

 

CONTEXT transformation.png

Simialry...inside an ITERATOR.... these two expressions behave differently

 


Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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