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
mic_rys
Helper I
Helper I

Count number of actual project per year to present

hi, i need a dax hero! 🙂
I need to count number of actual projects peer year to present.

If project has EndYear - should be counted between start and end year
sample of model:

IDStartYearEndYear
Proj120052007
Proj22005 
Proj320102012
Proj42010 
Proj520072008

 

The resuld should be:

Year        ActualProj

20052 proj1,2
20062 proj1,2
20073 proj1,2,3
20082 proj2,5
20091 proj2
20103 proj2,3,4
20113 proj2,3,4
20123 proj2,3,4
20132 proj2,4
2 proj2,4
20212 proj2,4

 

I tried something like this but it doesnt work properly:

 

ActualProj =
var toPresent =
CALCULATETABLE(
CALCULATETABLE(Projects,ISBLANK(Projects[StartYear]) = FALSE() && ISBLANK(Projects[EndYear]) = TRUE()),
FILTER(ALL(Date[Year]), Projects[StartYear] <=MAX(Date[Year]))
)
var toEndDate =
CALCULATETABLE(
CALCULATETABLE(Projects,ISBLANK(Projects[StartYear]) = FALSE() && ISBLANK(Projects[EndYear]) = FALSE()),
FILTER(ALL(Projects[Year]), Projects[StartYear] <=MAX(Projects[EndYear]))
)

return
COUNTX(UNION(toPresent,toEndDate),Projects[ID])

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @mic_rys 

 

Please check the below picture and the sample pbix file's link down below, whether it is what you are looking for.

 

The first step is to create a disconnected year table.

 

Picture1.pngPicture2.png

 

Projects Count =
CALCULATE (
COUNTROWS ( Projects ),
FILTER (
Projects,
Projects[StartYear] <= MAX ( Years[Year] )
&& OR ( Projects[EndYear] >= MIN ( Years[Year] ), Projects[EndYear] = BLANK () )
)
)
 
 
Project ID describe =
CALCULATE (
CONCATENATEX( Projects, Projects[ID],", "),
FILTER (
Projects,
Projects[StartYear] <= MAX ( Years[Year] )
&& OR ( Projects[EndYear] >= MIN ( Years[Year] ), Projects[EndYear] = BLANK () )
)
)
 
 
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @mic_rys 

 

Please check the below picture and the sample pbix file's link down below, whether it is what you are looking for.

 

The first step is to create a disconnected year table.

 

Picture1.pngPicture2.png

 

Projects Count =
CALCULATE (
COUNTROWS ( Projects ),
FILTER (
Projects,
Projects[StartYear] <= MAX ( Years[Year] )
&& OR ( Projects[EndYear] >= MIN ( Years[Year] ), Projects[EndYear] = BLANK () )
)
)
 
 
Project ID describe =
CALCULATE (
CONCATENATEX( Projects, Projects[ID],", "),
FILTER (
Projects,
Projects[StartYear] <= MAX ( Years[Year] )
&& OR ( Projects[EndYear] >= MIN ( Years[Year] ), Projects[EndYear] = BLANK () )
)
)
 
 
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Jihwan_Kim You are always there for us! Thanks a lot!

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.