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

Count number of projects with balance sum of zero

Hi 

 

Seeking assistance from an experienced Power BI user,

 

I am trying to count the number of the projects which have WIP Balance (sum('WIP Additions'[Addition Amount])

of nil (measure to be named Finished Projects).  Ultimately I am trying to work out how many projects have been finished (has nil balance) and which department (Parks, Water, or Transport) these projects belong to.  I have tried CALCULATE with COUNT and FILTER, but none of the formulas I've tried worked.

 

Thanks for your assistance.

 

Here is the link to the files.  

https://drive.google.com/file/d/17lBv76rF2B4vHolqjEhklXOrr1o5TEoc/view?usp=sharing

 

Report View.JPG

Data View.JPG

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Anonymous 

 

Below are a couple of ways you could rewrite your Finished Projects measure. I have adjusted the measure so that if filters values of 'Project Detail'[Project Number] as it is generally preferable to filter on dimension tables. However, you could change 'Project Detail'[Project Number] to 'WIP Additions'[Project Number] and the measures would still work 

 

Finished Projects = 
CALCULATE (
    DISTINCTCOUNT('Project Detail'[Project Number]),
    FILTER(
        VALUES ( 'Project Detail'[Project Number] ),
        [WIP Balance] = 0
    )
)

Or since you are counting projects, you could use this slightly simpler measure:

Finished Projects = 
COUNTROWS (
    FILTER(
        VALUES ( 'Project Detail'[Project Number] ),
        [WIP Balance] = 0
    )
)

A side note: I see a number of projects have very small WIP Balance values (positive or negative) so you may want to test for a WIP Balance that is close to zero. To do this you could adjust the condition to something like this:

Finished Projects within threshold = 
VAR Threshold = 0.001
RETURN
    COUNTROWS (
        FILTER(
            VALUES ( 'Project Detail'[Project Number] ),
            ABS ( [WIP Balance] ) < Threshold
        )
    )

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @Anonymous 

 

Below are a couple of ways you could rewrite your Finished Projects measure. I have adjusted the measure so that if filters values of 'Project Detail'[Project Number] as it is generally preferable to filter on dimension tables. However, you could change 'Project Detail'[Project Number] to 'WIP Additions'[Project Number] and the measures would still work 

 

Finished Projects = 
CALCULATE (
    DISTINCTCOUNT('Project Detail'[Project Number]),
    FILTER(
        VALUES ( 'Project Detail'[Project Number] ),
        [WIP Balance] = 0
    )
)

Or since you are counting projects, you could use this slightly simpler measure:

Finished Projects = 
COUNTROWS (
    FILTER(
        VALUES ( 'Project Detail'[Project Number] ),
        [WIP Balance] = 0
    )
)

A side note: I see a number of projects have very small WIP Balance values (positive or negative) so you may want to test for a WIP Balance that is close to zero. To do this you could adjust the condition to something like this:

Finished Projects within threshold = 
VAR Threshold = 0.001
RETURN
    COUNTROWS (
        FILTER(
            VALUES ( 'Project Detail'[Project Number] ),
            ABS ( [WIP Balance] ) < Threshold
        )
    )

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn
Anonymous
Not applicable

Hi @OwenAuger 

 

Thanks for your help.  And you were right the projects with tiny balances will create some issues for me, now I need to work out what is the best way to prevent this from happening.  Thanks again for your help.

Result.JPG

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.