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

## Finding equivalent to countifs in power bi

Hello Community!

you have helped me before, I am confident you can help me again

I need to replicate the formula used in the screen shot from excel into power bi. to get 1/0 if a milestone was completed based on Case ID_Milstone key (many rows becuase each row is an activity and there could be many activities to 1 milestone) and based on the 'actual end date' (if reported then it means the milestone is completed)I tried to use:

Milestone Completed = CALCULATE(MIN('case data'[Case ID_Milestone])|ALLEXCEPT('case data'|'case data'[Case ID_Milestone]|IF(ISBLANK('case data'[Actual End Date])|0|1)))

but I get an error: "The ALLEXCEPT function expects a table reference expression for argument '3', but a string or numeric expression was used."which I don't fully understand...

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: Finding equivalent to countifs in power bi

Hi @Allav

A simple test here

```Column = CALCULATE(COUNT(Sheet1[Actual End Date]),ALLEXCEPT(Sheet1,Sheet1[id-Milestone],Sheet1[Actual End Date_1]))

Column 2 = CALCULATE(COUNTA(Sheet1[id-Milestone]),ALLEXCEPT(Sheet1,Sheet1[id-Milestone],Sheet1[Actual End Date_1]))

Column 3 = IF([Column]=[Column 2],1,0)```

Best Regards

Maggie

3 REPLIES 3
Community Support Team

## Re: Finding equivalent to countifs in power bi

Hi @Allav

First let me confirm with your requirement.

For each id of different milestones, if a "Actual End Date" shows, it means this milestone is completed.

But it seems my understanding above doesn't meet the results in your screenshot in the last column.

Please check the reference below:

ALLEXCEPT Function (DAX)

CALCULATE Function (DAX)

FILTER Function (DAX)

Best regards

maggie

Frequent Visitor

## Re: Finding equivalent to countifs in power bi

each milestone has multiple rows in the table (since there are few activities accosiated to the milestone), so only if "actual end date" is shown for all the activities under the same milestone, the milestone would be completed. see for example, Case_ID_Milestone 1004_M1, there are 3 lines for it in the excel, only 2 have "actual end date" reported, hence in the "milestone completed" it is marked with 0, meaning milestone is not completed.

is it more clear?

Community Support Team

## Re: Finding equivalent to countifs in power bi

Hi @Allav

A simple test here

```Column = CALCULATE(COUNT(Sheet1[Actual End Date]),ALLEXCEPT(Sheet1,Sheet1[id-Milestone],Sheet1[Actual End Date_1]))

Column 2 = CALCULATE(COUNTA(Sheet1[id-Milestone]),ALLEXCEPT(Sheet1,Sheet1[id-Milestone],Sheet1[Actual End Date_1]))

Column 3 = IF([Column]=[Column 2],1,0)```

Best Regards

Maggie