Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Filter Data based on a specific row value

Hello,

 

I have a table with a list of milestones for each project in a vertical manner along with the milestone date and status. I want to be able to filter to specific projects from the table based on a specific milestone status. For example, here is the source table:

 

 

In this example above, I want to count projects that only have Project Finalized = Complete. So basically, a measure that will count the Project_cd and return Project_cd = 1000 and 1003. 10001 should be skipped because it's not complete.

 

There could be various factors too. The end user could only want to look at Projects that are "Started", or both "Started and Complete". The way I want the final results to look like is a matrix that has the milestones across based on Project Finalized = Complete. That way, you can do Count(Project_Cd) against how many Projects are initialized, how many approved, assigned etc.

 

Project InitializationFunding ApprovedResources AssignedProject Finalized
2122

 

Funding Approved is only 1 because it's not completed. So far I've gotten to: calculate( count(Project_cd) , ALL(Table), Table[Milestone] = "Project Finalized") but I'm hitting a roadblock. It's just aggregating the final milestone's project count.

 

Thanks for the help!

 

6 Replies

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi, Anonymous 

    Based on my research, you could try this formula:

    Result = 
    CALCULATE (
        COUNTA ( 'Table'[Project_Cd] ),
        FILTER (
            'Table',
            CALCULATE (
                MAX ( 'Table'[Milestone_Status] ),
                FILTER (
                    ALLEXCEPT ( 'Table', 'Table'[Project_Cd] ),
                    'Table'[Milestone] = "Project Finalized"
                )
            ) = "Complete"
                && 'Table'[Milestone_Status] = "Complete"
        )
    )

    Or split it into two measure

    Measure = CALCULATE(MAX('Table'[Milestone_Status]),FILTER(ALLEXCEPT('Table','Table'[Project_Cd]),'Table'[Milestone] = "Project Finalized"))
    Measure 2 = 
    CALCULATE (
        COUNTA ( 'Table'[Project_Cd] ),
        FILTER (
            'Table',
            [Measure] = "Complete"
                && 'Table'[Milestone_Status] = "Complete"
        )
    )

    Result:

     

    Best Regards,

    Lin

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you, this gets me half way there actually! I completely forgot about a Milestone Dt slicer as well. So the user would want to see for example how many "Project Finalized" have been completed for Q1 2019. That would mean I will need to limit the query to only pull Projects that have Project Finalized between 1/1 and 3/31. All the other milestones must also be limited by not only the slicer, but their individual Project Finalized dates.  For example, I can't show 5 Project Approveds between Q1 and Q2  even though I have only 2 Project Finalizeds in Q1.  The 2 Project Approveds should be a subset of the 2 Project Finalized for Q1. Is there a way to limit this in DAX? Thanks in advance.

  • CALCULATE(
    COUNT('TBL'[PROJECT_CD] ),
    'TBL'[PROJECT_CD] = "1000")+CALCULATE(
    COUNT('TBL'[PROJECT_CD] ),
    'TBL'[PROJECT_CD] = "1003")

     

    may be missing a parenthesis but that should get you the counts for the codes that are equal to 1001 & 1003

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello, unfortunately this will not work. I think a better way to illustrate the problem I have is if I lay out my table horizontally.

       

       

       

      Keep in mind this is just for illustrative purposes: My table is vertical and not horizontal as shown above.

       

      Other thing was that the end user wants to plan based on Project Finalized date slicer so they can plan whats coming up for Q2, Q3 for example.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Bumping :P

     

    Any takers?