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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

I want to count and reflect the number of reason codes against each row

Below is the table and count of Reason code is the result I am trying to get in power BI. In first coloumn same Document number is there and against each document either there is reason code present or not present . I want to count and reflect the number of reason codes against each row . 

 

For eg. 123 document has total of 3 reason codes. so 3 count will reflect against each 123 row.

my excel formula to claculate count of reason code is : 

Capture.PNG

 

 

 

 

 

 

 

 

 

 

DocsReason CodeReason Code (Y/N)Count of Reason code
123x13
123003
123x13
123x13
231001
231x11
231001
231001

 

I tried below DAX formula but it is giving me the total of all reason codes. But I want sum of Reason code come against each document =

call = CALCULATE(COUNTAX(Sheet1,Sheet1[Order Number]),FILTER(Sheet1,Sheet1[reasoncode1]>0))

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous 

 

Try following

 

=
CALCULATE ( SUM ( Sheet1[reasoncode] ), ALLEXCEPT ( sheet1, sheet1[Docs] ) )

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

You could try this as well:

 

[Count of Reason Codes] =
var __oneDocVisibleAndDirectltyFiltered = HASONEFILTER( T[Docs] )
var __reasonCodeCount =
	CALCULATE(
		SUM ( T[Reason Code (T/N)] ),
		VALUES( T[Docs] ),
		ALL( T )
	)
return
	if(
		__oneDocVisibleAndDirectlyFiltered,
		__reasonCodeCount
	)

Best

Darek

Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous 

 

Try following

 

=
CALCULATE ( SUM ( Sheet1[reasoncode] ), ALLEXCEPT ( sheet1, sheet1[Docs] ) )
Anonymous
Not applicable

This is working. Thanks dude.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.