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, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

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, @Anonymous 

 

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, @Anonymous 

 

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.

 

 

amitchandak
Super User
Super User

@Anonymous , 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])

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

@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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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