Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Multi-condition table

Hello PBI community,

I have a problem which requires (re)building a table with multiple columns based on multiple conditions per column.

 

Problem statement:

- I have a database which contains multiple projects in the organization. Each project goes through 5 stages: 1 - Concept, 2 - Feasibility, 3 - Execution, 4 - Closure, Completed. Every update of the project, be it an update on the content of the phase or when changing the phase generates a new entry in the database, with its corresponding date of the update. This means that each project creates multiple entries in the database.

 

What I try to achieve:

- I want to create a new table which will have the following columns:

- 1. List of projects (unique)

- 2. Date when the project got into 1 - Concept

- 3. Days that the project stayed in 1 - Concept 

- 4. Date when the project got into 2 - Feasibility

- 5. Days that the project stayed in 2 - Feasibility 

- ... same logic for the rest of the phases

- I then want to find out:

- how many projects do I have in the pool (total)? how many projects do I have in each stage? 

- what is the actual velocity of the projects? how long do they stay in a certain stage

- what is the average velocity of the projects? how long do they stay on average in a certain stage

- what is the conversion rate relative to Stage 1 - Concept? e.g. how many projects made it to Stage 2, 3, 4, Completed (in percentage) - in the current data table the answer will be 100% since all made it to the end but I would like to know the logic/formula

- what is the conversion rate relative to the previous stage? e.g. how many projects from stage 1 - Concept made it to stage 2 - Feasibility, how many from Feasibility made it to Execution etc. - in the current data table the answer will be 100% since all made it to the end but I would like to know the logic/formula

- since some projects spill into the next year, I would like to show that some projects have been completed in 2021 while others in 2022

- how would everything above look like if I add one more dimension - Project type (Software, Hardware, Infrastructure)

 

Where I am today (and caveats):

- The output table is done manually, I visually inspect the data and copy/paste the date when the project changed stages

- I was able to get in PowerBI only Column 1 by creating a new table and using DISTINCT('Source'[Project name])

- I can get in XLS how many days the project stayed in a certain stage by subtracting one phase date from the next one (e.g. to get Column 3 (Days in 1 - Concept), I do Column 4 - Column 2. I need to find how to do this in PowerBI
- I think the logic for the output table could be something along the following line (only for Column 2. Date when the project got into 1 - Concept):
- find the project from Output(A2) in Source(A2)
- get the minimum date corresponding to stage 1- Concept
 
I hope I articulated the problem well enough and it would be great if someone could answer. I fully understand the logic, I just lack the skills to put it in practice.
 
Best,
M
 

Source table:

Project nameFrom StageTo Stage DateProj Mgr.
Alpha 1 - Concept01/03/2021John
Bravo 1 - Concept01/04/2021Mike
Alpha1 - Concept1 - Concept10/03/2021John
Alpha1 - Concept1 - Concept12/03/2021John
Charlie 1 - Concept 01/09/2021Ann
Delta 1 - Concept01/12/2021Ann
Delta1 - Concept 2 - Feasibility01/12/2021Ann
Delta2 - Feasibility3 - Execution01/12/2021Ann
Delta3 - Execution4 - Closure20/12/2021Ann
Delta4 - ClosureCompleted20/01/2022Ann
Alpha1 - Concept2 - Feasibility02/04/2021John
Alpha2 - Feasibility2 - Feasibility20/04/2021John
Bravo1 - Concept1 - Concept05/04/2021Mike
Bravo1 - Concept2 - Feasibility10/05/2021Mike
Charlie1 - Concept 2 - Feasibility01/11/2021Ann
Alpha2 - Feasibility3 - Execution05/05/2021John
Alpha3 - Execution3 - Execution09/09/2021John
Alpha3 - Execution4 - Closure10/10/2021John
Charlie2 - Feasibility3 - Execution15/12/2021Ann
Charlie3 - Execution3 - Execution10/01/2022Ann
Charlie3 - Execution3 - Execution20/01/2022Ann
Charlie3 - Execution3 - Execution01/03/2022Ann
Bravo2 - Feasibility2 - Feasibility15/05/2021Mike
Alpha4 - ClosureCompleted15/11/2021John
Bravo2 - Feasibility2 - Feasibility01/06/2021Mike
Bravo2 - Feasibility1 - Concept01/07/2021Mike
Bravo1 - Concept1 - Concept10/07/2021Mike
Bravo1 - Concept2 - Feasibility20/07/2021Mike
Bravo2 - Feasibility3 - Execution18/08/2021Mike
Bravo3 - Execution3 - Execution10/09/2021Mike
Bravo3 - Execution4 - Closure01/10/2021Mike
Bravo4 - ClosureCompleted15/10/2021Mike
Charlie3 - Execution4 - Closure10/04/2022Ann
Charlie4 - ClosureCompleted15/05/2022Ann

 

 

Output table:

Project1 - ConceptDays in Concept2 - FeasibilityDays in Feasibility3 - ExecutionDays in Execution4 - ClosureDays in ClosureCompletedPM
Alpha01/03/20213202/04/20213305/05/202115810/10/20213615/11/2021John
Bravo01/04/20213910/05/202110018/08/20214401/10/20211415/10/2021Mike
Charlie01/09/20216101/11/20214415/12/202111610/04/20223515/05/2022Ann
Delta01/12/2021001/12/2021001/12/20211920/12/20213120/01/2022Ann

 

  • Hi, Anonymous 

     

    You can try the following methods.

    Table = SUMMARIZE('Source table','Source table'[Project name],'Source table'[Proj Mgr.])

    Column:

    1 - Concept = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="1 - Concept"&&[Project name]=EARLIER('Table'[Project name])))
    2 - Feasibility = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="2 - Feasibility"&&[Project name]=EARLIER('Table'[Project name])))
    Days in Concept = [2 - Feasibility]-[1 - Concept]

    Change the column format to integer.

    3 - Execution = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="3 - Execution"&&[Project name]=EARLIER('Table'[Project name])))
    Days in Feasibility = [3 - Execution]-[2 - Feasibility]
    4 - Closure = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="4 - Closure"&&[Project name]=EARLIER('Table'[Project name])))
    Days in Execution = [4 - Closure]-[3 - Execution]
    Completed = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="Completed"&&[Project name]=EARLIER('Table'[Project name])))
    Days in Closure = [Completed]-[4 - Closure]

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

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

2 Replies

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, Anonymous 

     

    You can try the following methods.

    Table = SUMMARIZE('Source table','Source table'[Project name],'Source table'[Proj Mgr.])

    Column:

    1 - Concept = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="1 - Concept"&&[Project name]=EARLIER('Table'[Project name])))
    2 - Feasibility = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="2 - Feasibility"&&[Project name]=EARLIER('Table'[Project name])))
    Days in Concept = [2 - Feasibility]-[1 - Concept]

    Change the column format to integer.

    3 - Execution = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="3 - Execution"&&[Project name]=EARLIER('Table'[Project name])))
    Days in Feasibility = [3 - Execution]-[2 - Feasibility]
    4 - Closure = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="4 - Closure"&&[Project name]=EARLIER('Table'[Project name])))
    Days in Execution = [4 - Closure]-[3 - Execution]
    Completed = CALCULATE(MIN('Source table'[Date]),FILTER('Source table',[To Stage]="Completed"&&[Project name]=EARLIER('Table'[Project name])))
    Days in Closure = [Completed]-[4 - Closure]

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      It's working almost as expected. The reason for saying "almost" is that I missed 3 scenarios:

      1. A project can jump stages - for example project Echo entered 1 - Concept on the 1st of Jan and was moved directly into 3 - Execution on the 1st of Feb. This means it didn't go through 2 - Feasibility so the entry in 2 - Feasibility column is empty therefore columns Days in Concept and/or Days in Feasibility will fail the calculation

      2. A project can enter directly in 3 - Execution, which means the 1 - Concept and 2 - Feasibility will be empty so the Days in Concept/Feasibility will fail the calculation

      3. Since I am running the report/dashboard today, some projects may be in different stages - e.g. project Golf can be in 1 - Concept. In this scenario, Days in Concept should be Today() - [1 - Concept]

       

      I think the scenarios above can be done with some IF nesting (or ISBLANK). I'll give it a go and see what comes up. 

      Either way, thank you very much for the solution, it works like a charm. 

       

      Best,

      M