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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jaryszek
Memorable Member
Memorable Member

Sum vs DisctintCount - why Sum is faster?

Hello,

from vertipaq point of view:

Sum vs DisctintCount - why Sum is faster?

Can anybody explain?
Best,
Jacek


1 ACCEPTED SOLUTION
AnalyticPulse
Super User
Super User

hi @jaryszek 

sum is much faster than distinctcount in dax because the vertipaq engine treats the two operations very differently. when you do a sum, vertipaq only needs to scan through the column and add the numbers together. it doesn’t need to check anything about uniqueness or track previous values. the column is already compressed and organised in segments, so summing is almost a straight-line operation that the storage engine can do extremely fast.

distinctcount is a lot heavier. to get the number of unique values, vertipaq must build an internal dictionary or hash-set to track which values it has already seen. every new value must be compared against that set to see if it is new or a duplicate. that means more cpu work, more memory usage, and more formula engine activity, which is always slower. high-cardinality columns make it even slower, because more unique values means a bigger dictionary to maintain.

so the simple explanation is that sum is easy, while distinctcount is hard. sum just adds numbers, but distinctcount must constantly check, store, and compare values to build a list of uniques. this extra work is why distinctcount is almost always slower than sum in vertipaq.

 

Analytic Pulse Blog 
Docynx Productivity Tools 
Tool to Generate Realistic Sample Data Instantly online  

View solution in original post

2 REPLIES 2
AnalyticPulse
Super User
Super User

hi @jaryszek 

sum is much faster than distinctcount in dax because the vertipaq engine treats the two operations very differently. when you do a sum, vertipaq only needs to scan through the column and add the numbers together. it doesn’t need to check anything about uniqueness or track previous values. the column is already compressed and organised in segments, so summing is almost a straight-line operation that the storage engine can do extremely fast.

distinctcount is a lot heavier. to get the number of unique values, vertipaq must build an internal dictionary or hash-set to track which values it has already seen. every new value must be compared against that set to see if it is new or a duplicate. that means more cpu work, more memory usage, and more formula engine activity, which is always slower. high-cardinality columns make it even slower, because more unique values means a bigger dictionary to maintain.

so the simple explanation is that sum is easy, while distinctcount is hard. sum just adds numbers, but distinctcount must constantly check, store, and compare values to build a list of uniques. this extra work is why distinctcount is almost always slower than sum in vertipaq.

 

Analytic Pulse Blog 
Docynx Productivity Tools 
Tool to Generate Realistic Sample Data Instantly online  

thank you

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.