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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Promethes_2
Helper II
Helper II

COUNTROWS over range question

Hello,

 

I'm struggling with creating a measure that does the following:

 

     Sum the number of occurrences for each incident type for the previous week ending.

 

I have a table that has the following relevant fields (this is an abbreviated snap of my table):

 

Request Type

WeekEnding

Application

9/17/2016

Application

9/10/2016

Application

9/10/2016

Application

9/10/2016

Internal

9/10/2016

Internal

9/10/2016

New Development Request

9/3/2016

 

I am trying to return (for the snippet above, the actual data has more values matching the criteria):

 

Application = 4

Internal = 4

 

I created this measure:

 

RequestTypeCount = CALCULATE(COUNTROWS('Report'),FILTER('Report', 'Report'[Created On] < MAX('Report'[WeekEnding]) && 'Report'[Created On] >= MAX('Report'[WeekEnding]) - 7))

 

But I am getting extra counts for things I am expecting to be filtered out (values in red I'm not sure why they are being counted):

 

2016-09-19 22_19_02-Microsoft Edge.png

 

The total count should be 32 (21 Application + 11 Internal), any thoughts on what I'm doing wrong?

1 ACCEPTED SOLUTION
Promethes_2
Helper II
Helper II

I figured out the issue with my filter, which now works as expected:

 

BEFORE:

RequestTypeCount = CALCULATE(COUNTROWS('Report'),FILTER('Report', 'Report'[Created On] < MAX('Report'[WeekEnding]) && 'Report'[Created On] >= MAX('Report'[WeekEnding]) - 7))

 

AFTER:

RequestTypeCount = CALCULATE (COUNTROWS ( 'Report' ), FILTER ('Report','Report'[WeekEnding] < MAX ( 'Report'[WeekEnding]) && 'Report'[WeekEnding]>= ( MAX ( 'Report'[WeekEnding] ) - 7))

 

And now I get this, the only remaining question I have is where is that extra 1 coming from, it's not in the data? 32 is the correct count but I'm not sure why 1 is in there?

 2016-09-20 11_22_01-Support Dashboard v2 - Power BI Desktop.png

View solution in original post

5 REPLIES 5
Promethes_2
Helper II
Helper II

I figured out the issue with my filter, which now works as expected:

 

BEFORE:

RequestTypeCount = CALCULATE(COUNTROWS('Report'),FILTER('Report', 'Report'[Created On] < MAX('Report'[WeekEnding]) && 'Report'[Created On] >= MAX('Report'[WeekEnding]) - 7))

 

AFTER:

RequestTypeCount = CALCULATE (COUNTROWS ( 'Report' ), FILTER ('Report','Report'[WeekEnding] < MAX ( 'Report'[WeekEnding]) && 'Report'[WeekEnding]>= ( MAX ( 'Report'[WeekEnding] ) - 7))

 

And now I get this, the only remaining question I have is where is that extra 1 coming from, it's not in the data? 32 is the correct count but I'm not sure why 1 is in there?

 2016-09-20 11_22_01-Support Dashboard v2 - Power BI Desktop.png

Hi @Promethes_2,

 

I guess there are some records of "Request Type" in the table are empty values. You can uncheck the option "Show items with no data" for the column "Request Type".

 

q3.PNG

 

Bets Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

You are correct about there being an empty row.  I guess I was thrown off by the fact that is shows the empty row with a value of 1 but it does not reflect in the total (21 + 11 + 1 = 33 not 32 as PBI is showing in the screenshot).

ankitpatira
Community Champion
Community Champion

@Promethes_2 Unless you provide your full data it would be hard to tell. Since calculation is not throwing any error and returning result I would say you do have data for all the categories shown in red where date falls between your date range specified in filter condition. If you can provide full data then I can have a look at why values are coming up when you're expecting them not to.

I've shared the data set here Data.xlsx and highlighted the columns that I'm expecting to be returned based on the filter. Hoping I'm just missing something simle.

 

Thank you for taking a look at this.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.