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
tony_BI34fr
Frequent Visitor

Number of active projects per month knowing start date and end date

Hi Power BI Community,

 

I am trying to create a measure to know the number of active projects per project manager per month.

 

My source data looks like this:

projectsProject Managerstart dateend date
projet 1PM1March-22null
projet 2PM2April-22May-22
projet 3PM1February-22May-22
projet 4PM1March-22July-22
projet 5PM3March-22August-22
projet 6PM2April-22null
projet 7PM4February-22null
projet 8PM4March-22June-22

 

I would like my result in Power BI to look like this:

 January-22February-22March-22April-22May-22June-22July-22August-22September-22October-22November-22December-22
PM1013322111111
PM2000211111111
PM3001111100000
PM4012221111111

 

I feel like it's not too difficult but somehow I can't wrap my head around this!

 

Let me know if you need more information.

 

Thank you

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@tony_BI34fr 
Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
tony_BI34fr
Frequent Visitor

OK, it gets interesting.

As stated above, it works nicely in Power BI Desktop. When I publish it to the service and refresh the dataset, it breaks the count! 

Final update: 

For some reason, updating the dataset in Power BI desktop was working smoothly, however, as stated above, updating the dataset from the Power BI Service was no working properly. The cause was that the MySQL database (on-prem with a data gateway) startDate and endDate columns were sometimes null or 0000-00-00. The later was not working with the Power BI Service.  

I then changed my SQL query to null those messy dates.

tony_BI34fr
Frequent Visitor

Thank you for your replies. I currently don't have the time to test all this but I'll get back to you.

 

Thanks again.

 

edit: I accepted Greg's solution as it is more adapted to my need.

The first link you provided works beautifuly !

 

Thank you very much

 

Based on the source data I provided above, the working measure is:

 

Projects Open =
VAR tmpProjects = ADDCOLUMNS('data',"Effective Date",IF(ISBLANK([end date]),TODAY(),[end date]))
VAR tmpTable =
SELECTCOLUMNS(
FILTER(
GENERATE(
tmpProjects,
'date'
),
[date] >= [start date] &&
[date] <= [Effective Date]
),
"ID",[projects],
"Date",[date]
)
VAR tmpTable1 = GROUPBY(tmpTable,[ID],"Count",COUNTX(CURRENTGROUP(),[date]))
RETURN COUNTROWS(tmpTable1)

 

This is assuming there is a non joined calendar table named 'date' containing the column [date] (created using Power Query for this test).

v-yangliu-msft
Community Support
Community Support

Hi  @tony_BI34fr ,

 

Here are the steps you can follow:

1. Power Query – Select [start date] , [end date] – Transform – Unpivot Columns.

vyangliumsft_0-1673847693856.png

Result:

vyangliumsft_1-1673847693859.png

2. Rows – [Project Manager] , Columns – [Value] , Value –Set [Projects]  to Count.

vyangliumsft_2-1673847693860.png

3. Result:

vyangliumsft_3-1673847693862.png

 

Best Regards,

Liu Yang

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

Greg_Deckler
Super User
Super User

@tony_BI34fr 
Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.