Forum Discussion

NadineNicolle's avatar
NadineNicolle
Regular Visitor
7 months ago
Solved

New and Old Projects

Hi PowerBI experts!  I am working on a visual that should show which new projects started, and which ones are gone and thus closed, compared with last month.  The data is as follows: I have a m...
  • JamieHolding's avatar
    7 months ago

    As I see it, you have 3 cases.

    A - A project is New
    B - A project is Ongoing
    C - A Project is Closed

    I would suggest breaking these out into a flag that says "Closed", "Ongoing", "Open" that you can then use in any visualisation, say, a table.

    The calculated column could be created with this:

    Status = 

    VAR CurrentProjectID = 'Projects'[ProjectID]

    VAR LatestMonth = MAX('Projects'[Date])

    VAR FirstAppearance =

    CALCULATE(

    MIN('Projects'[Date]),

    FILTER(

    ALL('Projects'),

    'Projects'[ProjectID] = CurrentProjectID

    )

    )

    VAR LastAppearance =

    CALCULATE(

    MAX('Projects'[Date]),

    FILTER(

    ALL('Projects'),

    'Projects'[ProjectID] = CurrentProjectID

    )

    )

    VAR IsInLatestMonth = LastAppearance = LatestMonth

    VAR IsFirstInLatestMonth = FirstAppearance = LatestMonth




    RETURN

    SWITCH(

    TRUE(),

    NOT(IsInLatestMonth), "Closed",

    IsFirstInLatestMonth, "New",

    "Ongoing"

    )

     This assumes the table is called Projects, the ID is ProjectID, and the date is Date.

     

    Test Data

     

    Sample Output

    Edit : correction of "Closed", "Ongoing", "Closed" to have one "Open"