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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Countrows to include and display 0 values

Hello PowerBI community,

 

I did a measure to give a number of status updates per project, for a given period (filter dates). For this I use the COUNTROWS() function and it works well.

IvyM_0-1636450791934.png

 

Now I want to have a list of projects with 0 counts, OR I don't think it's possible with countrows() which is counting only if a row exists - logic...
Can someone advise me for a workaround ?

 

Thank you a lot in advance !

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you all very much for your answers.

@amitchandaknice one ! I thought it would work but never got a suggestion on-click to see no-data elements for this measure 😕

 

What finally worked was this :

Status updates count = VAR statusNb = CALCULATE (
COUNT ( 'Table'[Status Date] ),
ALLSELECTED ( 'Table' ),
VALUES ( 'Table'[Project] )
)
RETURN
IF(statusNb=0, 0, statusNb)
 
So instead of using countrows(), I am more explicit by using the field "Project", targeting correctly all projects with corresponding names and it gives me even those with 0 counts. It martches with what I egt manually.
I put this measure in Filters and I locked the filter so it displays only a table with 0 at anytime.
 
Hope it serves to someone with the same prolem.
Unfortunately I couldn't find a workaround by using countows().

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thank you all very much for your answers.

@amitchandaknice one ! I thought it would work but never got a suggestion on-click to see no-data elements for this measure 😕

 

What finally worked was this :

Status updates count = VAR statusNb = CALCULATE (
COUNT ( 'Table'[Status Date] ),
ALLSELECTED ( 'Table' ),
VALUES ( 'Table'[Project] )
)
RETURN
IF(statusNb=0, 0, statusNb)
 
So instead of using countrows(), I am more explicit by using the field "Project", targeting correctly all projects with corresponding names and it gives me even those with 0 counts. It martches with what I egt manually.
I put this measure in Filters and I locked the filter so it displays only a table with 0 at anytime.
 
Hope it serves to someone with the same prolem.
Unfortunately I couldn't find a workaround by using countows().
Icey
Community Support
Community Support

Hi @Anonymous ,

 

First, please check if what @amitchandak mentioned could work in your scenario.

 

If this doesn't work, maybe there are no complete data for projects and you need to create another table with the complete list of projects. And here is an example: Solved: blanks as 0s, +0 not working as expected - Microsoft Power BI Community.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @Anonymous 

 

Do you have another table with a list of all projects?

Can you share a sample of your data in a table format?

 

Appreciate your Kudos!!

 

amitchandak
Super User
Super User

@Anonymous , You can try Countows(Table)+0  in the  measure or the option, Show item with No date

 

ShowItemwithoutdata.JPG

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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