Forum Discussion
Translate COUNTIFS solution from Excel to Power BI - Counting number of historic outstanding rows
Looking for some assistance as to a starting point for the below requirement.
I have simplified my dataset as per below. The context is as follows
- We have two milestones we must achieve per project undertaken.
- Each Milestone has a Due date once active. (8 weeks in this simplistic example)
- Milestone 2 does not become active until Milestone 1 is completed.
- The data available tells me when the Due Date is and if completed what week it was completed in.
- If the Milestone is not active it will not have a due date and is therefore not required to be assessed / part of the summary.
| Year | Project | Region | Area | Milestone | Due Week | Status | Completion Week |
| 2021 | 20A | UK | North UK | 1 | 21.08 | Completed | 21.11 |
| 2021 | 20B | UK | South UK | 1 | 21.16 | Completed | 21.20 |
| 2021 | 20C | EUR | West Eur | 1 | 21.20 | Completed | 21.30 |
| 2021 | 20D | EUR | East Eur | 1 | 21.24 | Completed | 21.25 |
| 2021 | 20E | US | North US | 1 | 21.36 | Completed | 21.38 |
| 2021 | 20F | US | South US | 1 | 21.42 | Completed | 21.42 |
| 2021 | 20A | UK | North UK | 2 | 21.19 | Completed | 21.25 |
| 2021 | 20B | UK | South UK | 2 | 21.28 | Completed | 21.30 |
| 2021 | 20C | EUR | West Eur | 2 | 21.38 | Completed | 21.45 |
| 2021 | 20D | EUR | East Eur | 2 | 21.33 | Completed | 21.50 |
| 2021 | 20E | US | North US | 2 | 21.46 | Completed | 21.48 |
| 2021 | 20F | US | South US | 2 | 21.50 | Completed | 21.50 |
| 2022 | 21A | UK | North UK | 1 | 22.08 | Completed | 22.09 |
| 2022 | 21B | UK | South UK | 1 | 22.16 | Completed | 22.20 |
| 2022 | 21C | EUR | West Eur | 1 | 22.20 | Completed | 22.28 |
| 2022 | 21D | EUR | East Eur | 1 | 22.24 | Completed | 22.30 |
| 2022 | 21E | US | North US | 1 | 22.36 | Not Started | |
| 2022 | 21F | US | South US | 1 | 22.42 | Not Started | |
| 2022 | 21A | UK | North UK | 2 | 22.17 | Completed | 22.20 |
| 2022 | 21B | UK | South UK | 2 | 22.28 | Completed | 22.33 |
| 2022 | 21C | EUR | West Eur | 2 | 22.36 | Not Started | |
| 2022 | 21D | EUR | East Eur | 2 | 22.38 | Not Started | |
| 2022 | 21E | US | North US | 2 | 1 not complete | ||
| 2022 | 21F | US | South US | 2 | 1 not complete |
The type of output I initially want to achieve is as below. I have chosen the Area field as the 'row' data but would like the ability to also display this by the other fields, such as Year, Project, Region etc.
It shows for any given week how many Milestones were outstanding.
The intention is that each milestone would have it's own table, so the below is based on milestone 1
Obviously this is meant to account for all weeks whereas the data set only tells us when a milestone was due and if and when it was completed.
[The weeks are a combo of year and week number]
I have achieved the above in excel with the following formula ;
=COUNTIFS(Data[Milestone],1,Data[Due Week],"<="&L$1,Data[Status],"Not Started",Data[Area],[@Area])
+
COUNTIFS(Data[Milestone],1,Data[Due Week],"<="&L$1,Data[Status],"Completed",Data[Area],[@Area],Data[Completion Week],">"&L$1)
[L$1 refers to the header in the count table and is the week numbers, this increments horizontally]
The above is essentially adding the "Not Started" (which were overdue for a reporting week) and those now "Completed" which were not completed (ie overdue) at the time of the reporting week. The context is for Milestone 1 in each Area.
I am looking for a starting point as I have with my limited knowledge tried a few different approaches that have produced nothing that works.
My intuition is that I require some kind of framework table which supplies the structure of the output required. A calculated column or measure may then be required to count the rows.
I have tried the above with limited success using CALCULATE(COUNTROWS(FILTER dax commands
I was unsure which field to relate the table to as I have two weeks field in my raw data. Nothing attempted has yielded anything encouraging yet.
Any help would be gladly received.
1 Reply
- AnonymousNot applicable
Hi baseballtheory ,
I'm a little confused about your needs, Could you please explain them further? It would be good to provide a screenshot of the results you are expecting.
Thanks for your efforts & time in advance.
Best regards,
Community Support Team_ Binbin Yu