Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
wmoskal99
New Member

How do I get the state of a project from the state history table at a given date?

Hello,

 

Background: I'm working on a report with a table containing project details and a table that contains the state history for all projects.

 

Issue: I am trying to get the count of statuses for projects at a given date. For example If I set the date to be October 1st, 2022, I should get a count of 3 for "new" and a count of 3 for "active" (Project 1, 4, and 6 would be active on this date, and project 2, 5, and 7 would be new, project 3 would not exist at this point in time).  

 

Sample Data:

State History Table
 id      State          Date updated

1newSaturday, July 16, 2022
1activeSaturday, October 1, 2022
1on holdTuesday, October 11, 2022
1activeMonday, October 17, 2022
1completeWednesday, November 2, 2022
2newSaturday, October 1, 2022 
3newSunday, October 16, 2022
3activeMonday, November 14, 2022
4newWednesday, July 20, 2022
4activeSaturday, October 1, 2022
4on holdWednesday, October 12, 2022
5newTuesday, July 19, 2022
5activeSunday, October 2, 2022
6newTuesday, July 19, 2022
6activeSaturday, October 1, 2022
7newWednesday, July 20, 2022

 

Projects Table 

 Id      Title

1Design Database
2Design API
3Build Frontend
4Build Database
5Build API
6Design Frontend
7Integrate


Relationship

wmoskal99_0-1668790737327.png

How would I go about doing this?
Thanks for the help!

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

@wmoskal99 

 

Here's how I'd do it.

Create a new table (call it, say, Stats) that will store for each project (using Power Query it's simple):

ProjID | Status | Day

The Day column will hold every single day in which the project has the Status. Yes, you want to expand your rows in the table above into a table that has the day granularity. Connect your Projects, Statuses and Calendar dimensions (you've got them, right?) to the table on the relevant fields.

Once this is done, it's all easy-peasy (and fast!) to do all kinds of calculations. Want to see the number of projects that on a particular day have a certain status? Well, drop the status and day onto a table/matrix, create this measure:

[# Projects] = distinctcount( Stats[ProjectID] )

and drop it onto the visual as well.

 

Now you're done.

 

(By the way, this is how you create professional models which need to calculate fast.)

Thanks for the response @daXtreme

Just so I'm clear, 
If say, project 1 has a "new" status from October 1st to 7th, the table would look like:

idstatusday
1new10/1/2022
1new10/2/2022
1new 10/3/2022
1new10/4/2022
1new10/5/2022
1new10/6/2022
1new10/7/2022
1active10/8/2022
...  

 

Would it be possible to provided the m code for creating such a table in power query?

 

I also have some similar tables that are wider (such as date history), which contains target start, actual start, target end, and actual end dates for each project, as well as the date the project was updated on. Would this approach still be optimal for that? Is there and column breadth that would be too large for this approach to work?

Thanks again! 

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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