Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SanketBhagwat
Solution Sage
Solution Sage

Table should show hierarchical data according to slicer value.

Hello.

I have a table which contains hierarchical data as Groups->Divisions-> Functions.

I have added those 3 values in 3 different slicers.

What I want to show in the table is such that if I select the 'Group' slicer value, then the table should show only the corresponding divison value and not Groups and Functions.

Similar for 'Divisions', if i select on that slicer then it should show Functions in the table and not the other 2 column values.

If anyone knows any way to implement it, then please reply to this post.

 

I have also attached the screenshot of the data and the slicers.

 

 

Screenshot (91).png

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @SanketBhagwat ,

 

The table visual will not show dynamic columns, but you can create a matrix visual.Please follow the steps below:

 

1. Create an index column in your original table,

2.Create a new hierarchy table for columns in matrix visual:

Capture2.PNG

 

3. Create a new table for slicer:

 

Table 2 = UNION(SELECTCOLUMNS(Sheet,"value",Sheet[Groups],"child","Divisions","current","Groups"),SELECTCOLUMNS(Sheet,"value",Sheet[Divisions ],"child","Functions","current","Divisions"),SELECTCOLUMNS(Sheet,"value",Sheet[Functions ],"child","Functions","current","Function"))

 

4. Then create three slicer by the new value column from the table 2 and use the visual level filter to fix them to their hierarchy.

 

Capture3.PNG

 

5. Create the matrix visual by the new measure:

Measure = SWITCH (
    MAX ( Table3[Column2] ),
    "Group", MAX ( Sheet[Groups] ),
    "Divisions",
        IF (
            MAX ( 'Table 2'[current] ) = "Groups",
            CALCULATE (
                MAX ( Sheet[Divisions ] ),
                TREATAS ( VALUES ( 'Table 2'[value] ), Sheet[Groups] )
            ),
            MAX ( Sheet[Divisions ] )
        ),
    "Functions",
        SWITCH (
            MAX ( 'Table 2'[current] ),
            "Divisions",
                CALCULATE (
                    MAX ( Sheet[Functions ] ),
                    TREATAS ( VALUES ( 'Table 2'[value] ), Sheet[Divisions ] )
                ),
            "Function",
                CALCULATE (
                    MAX ( Sheet[Functions ] ),
                    TREATAS ( VALUES ( 'Table 2'[value] ), Sheet[Functions ] )
                )
        ,MAX(Sheet[Functions ]))
)

 

Capture4.PNG

 

 

test.gif

 

Please refer to the pbix file.

 

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

 

Best Regards,

Dedmon Dai

 

 

View solution in original post

5 REPLIES 5
v-deddai1-msft
Community Support
Community Support

Hi @SanketBhagwat ,

 

The table visual will not show dynamic columns, but you can create a matrix visual.Please follow the steps below:

 

1. Create an index column in your original table,

2.Create a new hierarchy table for columns in matrix visual:

Capture2.PNG

 

3. Create a new table for slicer:

 

Table 2 = UNION(SELECTCOLUMNS(Sheet,"value",Sheet[Groups],"child","Divisions","current","Groups"),SELECTCOLUMNS(Sheet,"value",Sheet[Divisions ],"child","Functions","current","Divisions"),SELECTCOLUMNS(Sheet,"value",Sheet[Functions ],"child","Functions","current","Function"))

 

4. Then create three slicer by the new value column from the table 2 and use the visual level filter to fix them to their hierarchy.

 

Capture3.PNG

 

5. Create the matrix visual by the new measure:

Measure = SWITCH (
    MAX ( Table3[Column2] ),
    "Group", MAX ( Sheet[Groups] ),
    "Divisions",
        IF (
            MAX ( 'Table 2'[current] ) = "Groups",
            CALCULATE (
                MAX ( Sheet[Divisions ] ),
                TREATAS ( VALUES ( 'Table 2'[value] ), Sheet[Groups] )
            ),
            MAX ( Sheet[Divisions ] )
        ),
    "Functions",
        SWITCH (
            MAX ( 'Table 2'[current] ),
            "Divisions",
                CALCULATE (
                    MAX ( Sheet[Functions ] ),
                    TREATAS ( VALUES ( 'Table 2'[value] ), Sheet[Divisions ] )
                ),
            "Function",
                CALCULATE (
                    MAX ( Sheet[Functions ] ),
                    TREATAS ( VALUES ( 'Table 2'[value] ), Sheet[Functions ] )
                )
        ,MAX(Sheet[Functions ]))
)

 

Capture4.PNG

 

 

test.gif

 

Please refer to the pbix file.

 

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

 

Best Regards,

Dedmon Dai

 

 

I tried the same steps in my file.

But my matrix didn't exactly gave the output which you got in your file.

Although I implemented the same steps.

My matrix sliced correct data but it displayed the other 2 column values along with it too.

 

I have attached screenshot of it.

 

Screenshot (96).png

Hi @SanketBhagwat ,

 

You need to create bi-direction relationship between table 2 and table3, by child column and new column in table3.

 

Capture11.PNG

 

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

 

Best Regards,

Dedmon Dai

Greg_Deckler
Super User
Super User

@SanketBhagwat No way that I know of to essentially have dynamic columns in the table. You could potentially create measures and use HASONEVALUE or ISFILTERED to determine what is or is not filtered. See this dynamic title measure example for how you can use these functions. You would return BLANK in the event that you don't want to show values in certain situations. https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Most-Amazing-Mind-Blowing-Dynamic-Slicer...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
SanketBhagwat
Solution Sage
Solution Sage

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.