Forum Discussion

Rani301170's avatar
Rani301170
New Member
1 year ago
Solved

Show rows based on selected filter in another column

I have a table as below with a filter for Project. I want to display, in a table, all the Projects with the same Parent when the Project selected equals a Parent. Example: Filter Project on "bbb", the table returns 1b, 2b, 3b, 4b as they all have the Parent "bbb". I don't want to filter on the "Parent" as I want to be able to show Projects that don't have a Parent in the table too. 

business areaProjectParent
21bbbb
52bbbb
73bbbb
144bbbb
20bbbddd
221dddd
242dddd
13dddd
34dddd
45dddd
66dddd
87dddd
98dddd
10dddxxx
121xxxx
132xxxx
153xxxx
164xxxx
175xxxx
  • Hi Rani301170 ,

     

    To achieve this in Power BI, you can first create a disconnected slicer table using the formula Project Selector = DISTINCT('YourTable'[Project]). This table will serve as the slicer so that selecting a project doesn't directly filter your main table, giving you more control over the logic.

    Next, create a calculated table that returns all the projects sharing the same Parent as the selected project, but only when the selected project is a Parent. Otherwise, it will simply return the selected project. Use the following DAX for the calculated table:

    Filtered Projects = 
    VAR SelectedProject = SELECTEDVALUE('Project Selector'[Project])
    VAR SelectedParent =
        CALCULATE(
            MAX('YourTable'[Parent]),
            'YourTable'[Project] = SelectedProject
        )
    VAR IsSelectedAParent =
        CALCULATE(
            COUNTROWS('YourTable'),
            'YourTable'[Parent] = SelectedProject
        ) > 0
    RETURN
        IF(
            IsSelectedAParent,
            FILTER(
                'YourTable',
                'YourTable'[Parent] = SelectedProject
            ),
            FILTER(
                'YourTable',
                'YourTable'[Project] = SelectedProject
            )
        )
    

    This logic ensures that if a user selects "bbb", which is a Parent, the table will return all projects where the Parent is "bbb" (like 1b, 2b, 3b, 4b). If the selected project isn't a Parent, it will just return that project itself. You can use this calculated table in your visual to display the desired filtered results.

     

    Best regards,

4 Replies

  • Hi Rani301170 ,

     

    To achieve this in Power BI, you can first create a disconnected slicer table using the formula Project Selector = DISTINCT('YourTable'[Project]). This table will serve as the slicer so that selecting a project doesn't directly filter your main table, giving you more control over the logic.

    Next, create a calculated table that returns all the projects sharing the same Parent as the selected project, but only when the selected project is a Parent. Otherwise, it will simply return the selected project. Use the following DAX for the calculated table:

    Filtered Projects = 
    VAR SelectedProject = SELECTEDVALUE('Project Selector'[Project])
    VAR SelectedParent =
        CALCULATE(
            MAX('YourTable'[Parent]),
            'YourTable'[Project] = SelectedProject
        )
    VAR IsSelectedAParent =
        CALCULATE(
            COUNTROWS('YourTable'),
            'YourTable'[Parent] = SelectedProject
        ) > 0
    RETURN
        IF(
            IsSelectedAParent,
            FILTER(
                'YourTable',
                'YourTable'[Parent] = SelectedProject
            ),
            FILTER(
                'YourTable',
                'YourTable'[Project] = SelectedProject
            )
        )
    

    This logic ensures that if a user selects "bbb", which is a Parent, the table will return all projects where the Parent is "bbb" (like 1b, 2b, 3b, 4b). If the selected project isn't a Parent, it will just return that project itself. You can use this calculated table in your visual to display the desired filtered results.

     

    Best regards,

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Rani301170,

    Thank you for reaching out in Microsoft Community Forum.

    Thank you DataNinja777   for the helpful response.

    As suggested by DataNinja777,  I hope this information was helpful. Please let me know if you have any further questions or you'd like to discuss this further. If this answers your question, please "Accept as Solution" and give it a 'Kudos' so others can find it easily.

    Please continue using Microsoft community forum.

    Regards,
    Pavan.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Rani301170,

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please "Accept  as  Solution" and give a 'Kudos' so other members can easily find it.

    Thank you,
    Pavan.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Rani301170,

    I wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.
    If the community member's answer your query, please mark it as "Accept as Solution" and select "Yes" if it was helpful.
    If you need any further assistance, feel free to reach out.

    Please continue using Microsoft community forum.

    Thank you,
    Pavan.