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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
PS_78
Helper I
Helper I

SUMX with COUNT returns incorrect value

Hello All - I have issue with a measure created to calculate count using SUMX function. My requirement is to calculate count of document #'s where type = "TP1". But the measure I created returns incorrect values. It seems to be multiplication of Count (Sum of Count where type = TP1) with total count (Count of Doc #). In additional I also need to calculate distinct count for doc #, CC and Year combination. Please help check this. I am also giving a link of PBIX file here. SUMX Count Issue.zip 

 

Formula in the measure = 

Msr_Count = SUMX(FILTER('Table', 'Table'[Type] = "TP1"), COUNT('Table'[Doc #]))

 

PSivapuram_0-1715281988163.png 

Thanks,

Phani

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

lbendlin_0-1715295660417.png

 

 In additional I also need to calculate distinct count for doc #, CC and Year combination. 
DC = COUNTROWS(summarize('Table',[CC],[Doc #],[Year]))

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

lbendlin_0-1715295660417.png

 

 In additional I also need to calculate distinct count for doc #, CC and Year combination. 
DC = COUNTROWS(summarize('Table',[CC],[Doc #],[Year]))

Hi @lbendlin - Awesome. Thanks. But what is the issue with COUNT in SUMX? Also how can I get distinct count of rows for the combination of Doc #, Type and CC for the same document type?

Thanks,

@PS_78 

You can use a table visual for that

 

lbendlin_0-1715297416018.png

 

When you use the count inside the SUMX you are multiplying each row's filtered count with each row's unfiltered count.

 

If you need to use SUMX, use 

 

Msr_Count2 = SUMX(FILTER('Table', [Type] = "TP1"), 1)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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