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
Anonymous
Not applicable

Need help to apply count function on a measure

Hi Team,

 

I have to apply count function on a measure column, below is the logic used to create a measure column and please note it is mandatory to have the logic implemented in measure column only, because i'm also using another measure column in the below logic  (TargetCritical,TargetMedium ..etc) for a comparing target values which are dynamic values.

 

Target_hrs_Exceded_1.10_SUMX =
VAR var1 = SUMX(FILTER('Case','Case'[Priority] In {"critical","criticalEscalated"} && 'Case'[CaseStatus] In {"open"}),DATEDIFF('Case'[CaseCreatedDate],IF(YEAR('Case'[CaseClosedDateTime])>2000, 'Case'[CaseClosedDateTime],UTCNOW()),Hour))

VAR var2 = IF(var1>[TargetCritical],var1)


VAR var3 = SUMX(FILTER('Case','Case'[Priority] In {"high"} && 'Case'[CaseStatus] In {"open"}),DATEDIFF('Case'[CaseCreatedDate],IF(YEAR('Case'[CaseClosedDateTime])>2000, 'Case'[CaseClosedDateTime],UTCNOW()),Hour))

VAR var4 = IF(var3>[TargetHigh],var3)

VAR var5 = SUMX(FILTER('Case','Case'[Priority] In {"medium"} && 'Case'[CaseStatus] In {"open"}),DATEDIFF('Case'[CaseCreatedDate],IF(YEAR('Case'[CaseClosedDateTime])>2000, 'Case'[CaseClosedDateTime],UTCNOW()),Hour))

VAR var6 = IF(var5>[TargetMedium],var5)


VAR var7 = SUMX(FILTER('Case','Case'[Priority] In {"low"} && 'Case'[CaseStatus] In {"open"}),DATEDIFF('Case'[CaseCreatedDate],IF(YEAR('Case'[CaseClosedDateTime])>2000, 'Case'[CaseClosedDateTime],UTCNOW()),Hour))

VAR var8 = IF(var7>[TargetLow],var7)

VAR var9 = SUMX(FILTER('Case','Case'[Priority] In {"declined","noAnswer","noSymptom"} && 'Case'[CaseStatus] In {"open"}),DATEDIFF('Case'[CaseCreatedDate],IF(YEAR('Case'[CaseClosedDateTime])>2000, 'Case'[CaseClosedDateTime],UTCNOW()),Hour))

VAR var10 = IF(var9>[TargetOthers],var9)

var var11 = var2+var4+var6+var8+var10

RETURN var11
 
Thanks,
Venkat
2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , When you count a measure , you need force a level

 

example

 

countx(values(Table[case ID]), [Measure])

 

or

 

countx(summarize(Table,Table[case ID], Table[Country], "_1", [Measure]),[_1])

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Do you mean to say that before i apply count function on a measure, i have to make sure the output of measure column must be in the table format or row by row  format.

 

Please correct me if am wrong.

 

Thanks for quick response.

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.

Top Solution Authors
Top Kudoed Authors