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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
daniel_digi
New Member

Get Count of Rows for Table Visual Filtered by Measure

Hello,

 

I am having issues getting a row count of results based off a table being filtered by a measure. 

 

Simplified current table layout is: 

Table 1: Groups

Table 2: Activities 

 

Each group has a set of activities associated with them. Activities can have a status of completed, open, canceled and have a date field for when they were completed.

 

My requirement is that I want to get a list of groups that have no completed activities within a certain date range. I have achieved this by creating the following measure; 

 

Completed Activities = COUNTAX(FILTER('Activties', Activties[Status] = "Completed"), 'Activties'[ActivityID]) + 0

 

I add this to a table visual, and filter to "Completed Activities is 0", along with the ID of the group and I get a list of every group with 0 completed activities for that period. 

What I now need is a count of the groups. It appears you cannot change the aggregation of the Total row so all I am able to do is get a sum which equals 0.

 

Ideally I would like a Card to show the number, however you cannot apply the measure per group so I do not get a correct result.

A similar question was asked here https://community.powerbi.com/t5/Desktop/Count-of-rows-after-filtering-by-a-measure/m-p/64259#M26546 but did not address the grouping and has not been active since 2018.

Any help will be greatly appreciated!

1 ACCEPTED SOLUTION

@daniel_digi ,  Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

I doubt anything I added to remove date filter.

Add this to table as well Card and check

countx(filter(summarize(Groups, Groups[group code],"_1",COUNTX(FILTER('Activties', Activties[Status] = "Completed"), 'Activties'[ActivityID]) + 0),[_1]>0),[group code])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hello! Is there a way I can apply this solution but filtering measures? I've tried replicating it but it doesn't work for me because I don't want to filter a table by a measure, but to filter a measure by another measure.

amitchandak
Super User
Super User

@daniel_digi , Assumed two table are connected and the group has an ID column it can be a name too

 

Try

countx(filter(summarize(Groups, Groups[ID],"_1",COUNTAX(FILTER('Activties', Activties[Status] = "Completed"), 'Activties'[ActivityID]) + 0),[_1]>0),[ID])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Unfortunately that does not return the expected result. If I add a count column to the table I can see my expected result is 169 however this returns 609.
PBIDesktop_RQS4BeNYNp.png

While this does give me the count it's a bit ridiculous to have to include an entire column of 1s. 

 

Additionally, the measure you provided does not update when I change the date period. Apologies I initially included the above screen shot indicating I was also filtering dates by a slicer but it doesn't appear to have been embedded correctly.  

@daniel_digi ,  Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

I doubt anything I added to remove date filter.

Add this to table as well Card and check

countx(filter(summarize(Groups, Groups[group code],"_1",COUNTX(FILTER('Activties', Activties[Status] = "Completed"), 'Activties'[ActivityID]) + 0),[_1]>0),[group code])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak,

 

Your solution worked with 1 edit. I changed the > 0 to = 0.

 

Group Count = countx(filter(summarize(Groups, Groups[group code],"_1",COUNTX(FILTER('Activities', Activities[Status] = "Completed"), 'Activities'[ActivityID]) + 0),[_1]=0),[group code])

 

 This gave me the 169 result I expected, and changes correctly when I update the date slicer.

 

Thank you very much for your assitance!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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