cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Melmehal Frequent Visitor
Frequent Visitor

Count rows measure not counting total properly

Hi Power Bi Community, 

 

i created a measure that counts rows of when a "status" column = 5, and the same thing when the status = 9Capture9.PNG

I want to subtract the count of s5 from count of s9 so i created another measure called subtract. however sometimes the count of s5 is null and returns to me (0-1= -1). i created another measure with an if statement below: 

Measure = IF('quotelog (2)'[Count of S5]-'quotelog (2)'[Count of S9]=-1,0,'quotelog (2)'[Count of S5]-'quotelog (2)'[Count of S9]) 
 
it worked nicely: Capturef.PNG

but the totals are still the same... what i am trying to do is the following: 

 

Sum the count of s5 per employee BUT only subtract "count of s9" when count of s5 is not null.  so for alexi's case i would like the true sum of the column "measure" which is actually 1+0+1+1+1+0+1+1=6Capture88.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
mochabits Regular Visitor
Regular Visitor

Re: Count rows measure not counting total properly

Hi @Melmehal , you can try this one:

 

1. Create a calculated column:

 

 

Counts_Col = 
var x = CALCULATE(COUNT(quotelog[status]), quotelog[status] = "S5", quotelog[quote] = EARLIER(quotelog[quote]))
var y = CALCULATE(COUNT(quotelog[status]), quotelog[status] = "S9", quotelog[quote] = EARLIER(quotelog[quote]))
return IF(ISBLANK(x),0,x-y)
 
 
2. Create a measure:
Total-S5&S9 = SUM(quotelog[Counts_Col])
 
 

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Count rows measure not counting total properly

@Melmehal ,

 

Could you please clarify more details and show the sample data and expected result?

 

Regards,

Jimmy Tao

Melmehal Frequent Visitor
Frequent Visitor

Re: Count rows measure not counting total properly

Hi Jimmy, 

 

I just need the column called measure to sum up to 6 instead of 5

mochabits Regular Visitor
Regular Visitor

Re: Count rows measure not counting total properly

Hi @Melmehal , you can try this one:

 

1. Create a calculated column:

 

 

Counts_Col = 
var x = CALCULATE(COUNT(quotelog[status]), quotelog[status] = "S5", quotelog[quote] = EARLIER(quotelog[quote]))
var y = CALCULATE(COUNT(quotelog[status]), quotelog[status] = "S9", quotelog[quote] = EARLIER(quotelog[quote]))
return IF(ISBLANK(x),0,x-y)
 
 
2. Create a measure:
Total-S5&S9 = SUM(quotelog[Counts_Col])
 
 

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 169 members 1,928 guests
Please welcome our newest community members: