Forum Discussion

Cel87's avatar
Cel87
Frequent Visitor
3 years ago
Solved

Not sure how to Filter this.

Hi All,

 

I have a table with a column that looks at programs and a column that looks at phases and another column that has the status of the phases. I want to create another column that will return if  all phases are completed, then return 'completed, or if all phases are not started, then return 'not started', else return 'In Progress"

 

How would i do this in power bi.

 

 

Thank you in advance

  • I managed to figure this out.

    High_Level_Status =
    VAR TotalPhases = COUNTROWS(FILTER('Flight Plan', 'Flight Plan'[program] = EARLIER('Flight Plan'[program])))
    VAR CompletedPhases = COUNTROWS(FILTER('Flight Plan', 'Flight Plan'[program] = EARLIER('Flight Plan'[program]) && 'Flight Plan'[Phase Status] = "Completed"))
    VAR NotStartedPhases = COUNTROWS(FILTER('Flight Plan', 'Flight Plan'[program] = EARLIER('Flight Plan'[program]) && 'Flight Plan'[Phase Status] = "Not Started"))

    RETURN
        SWITCH (
            TRUE(),
            CompletedPhases = TotalPhases, "Completed",
            NotStartedPhases = TotalPhases, "Not Started",
            "In Progress"
        )

3 Replies

  • Arul's avatar
    Arul
    Icon for Super User rankSuper User

    Cel87 ,

    I belive this is your expectation,

    Column = SWITCH(
        TRUE(),
        DISTINCTCOUNT('Table'[Phase Status])=1 && 'Table'[Phase Status] = "Completed","Completed",
        DISTINCTCOUNT('Table'[Phase Status])=1 && 'Table'[Phase Status] = "Not Started","Not Started",
        "In Progress")
  • Cel87's avatar
    Cel87
    Frequent Visitor

    Thank you Arul Arul,

    That partly worked. However, I still have one that's returning 'In Progress', even through all status 'Not Started'.

    Any ideas why this may be?

     

     

  • Cel87's avatar
    Cel87
    Frequent Visitor

    I managed to figure this out.

    High_Level_Status =
    VAR TotalPhases = COUNTROWS(FILTER('Flight Plan', 'Flight Plan'[program] = EARLIER('Flight Plan'[program])))
    VAR CompletedPhases = COUNTROWS(FILTER('Flight Plan', 'Flight Plan'[program] = EARLIER('Flight Plan'[program]) && 'Flight Plan'[Phase Status] = "Completed"))
    VAR NotStartedPhases = COUNTROWS(FILTER('Flight Plan', 'Flight Plan'[program] = EARLIER('Flight Plan'[program]) && 'Flight Plan'[Phase Status] = "Not Started"))

    RETURN
        SWITCH (
            TRUE(),
            CompletedPhases = TotalPhases, "Completed",
            NotStartedPhases = TotalPhases, "Not Started",
            "In Progress"
        )