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

Help with the DAX Calculation

Hi, 

 

I have a requirement to count completed projects which has sub-task and each sub-task has a status field that has value 0(pending) or 1(completed). So, a project should be count as completed only if all these tasks have the status value set as 1. I want to use this measure/column in a clustered column graph and a table that will have all other details related to the project. Any help will be appreciated. 

Thanks.

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Kuneeka_S 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

 

You may create a measure as below.

Count Complete = 
var tab = 
SUMMARIZE(
    'Table',
    'Table'[Project],
    "Flag",
    var _project = [Project]
    return
    IF(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Project]=_project
            )
        )=
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Project]=_project&&
                'Table'[Task_Status]=1
            )
        ),1,0
    )
)
var _result = 
SUMX(
    tab,
    [Flag]
)
return
IF(
    ISBLANK(_result),
    0,
    _result
)

 

Result:

b2.png

 

Best Regards

Allan

 

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

 

 

View solution in original post

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @Kuneeka_S 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

 

You may create a measure as below.

Count Complete = 
var tab = 
SUMMARIZE(
    'Table',
    'Table'[Project],
    "Flag",
    var _project = [Project]
    return
    IF(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Project]=_project
            )
        )=
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Project]=_project&&
                'Table'[Task_Status]=1
            )
        ),1,0
    )
)
var _result = 
SUMX(
    tab,
    [Flag]
)
return
IF(
    ISBLANK(_result),
    0,
    _result
)

 

Result:

b2.png

 

Best Regards

Allan

 

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

 

 

View solution in original post

amitchandak
Super User
Super User

@Kuneeka_S , Try

countx(filter(summarize(table, table[project],"_1" ,distinctcount(table[sub project]) , "_2" , calculated( distinctcount(table[sub project]),table[sub project Status]) = "Closed"), [_1] =[_2]),[project])

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

@amitchandak  Thanks for the response.

But I'm still not getting the desired output. The result has projects having both completed and pending tasks.

 

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors