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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
dfarkas
Regular Visitor

Crosstab visualization with dynamically changing columns

Hello,

 

I have the following table:

Id     Column1    Column2     Column3   .... Column N

0      cat              male            house 

1      dog            male            car

2      cat              female         car

...

N

 

From this, I'd like to show the output for the user that can be visualized as a groupby table:

new_table = SUMMARIZE(table,[COLUMNS THAT ARE SPECIFIED BY THE USER], "Count", DISTINCTCOUNT(table[Id]))
 
Two requirements: 
- this type of matrix visualization
- always with the columns the user specified
 
I could easily solve this with python/dash, but I couldn't find a good solution with Power BI in the last two workdays...
 

 

8 REPLIES 8
Anonymous
Not applicable

Hi @dfarkas ,

 

Could you tell me if my post helps you ? If it is, kindly Accept it as the solution to make the thread closed. More people will benefit from it.

 

Best Regards,
Eyelyn Qin

Sorry, it didn't help

Anonymous
Not applicable

Hi @dfarkas ,

 

When you change the value of slicers , the value generated is dynamic.

You could not pass this to a Calculated Table or a Calculated Column.

 

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

Anonymous
Not applicable

Hi @dfarkas ,

 

If you just want the expected output , you could drag the Id field to Values and choose "Count" summarized type like this:

Eyelyn9_2-1633919801428.png

 

 

Or you could use the following formula to create a summarized table:

NewTable = SUMMARIZE('Table','Table'[Column1],'Table'[Column2],"Count",COUNTROWS('Table'))

Eyelyn9_3-1633919866974.png

 

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

Hello Eyelyn,

 

Thank you for your support. This is what I want and I could do this.

What I'm struggling with is to include a slicer (or slicers) which let's the user choose which columns to include.

E.g only Column 1, or Column 2 and 3, or all of them. (In my actual data, I have 38 columns and 1 to 3 selections should be possible to the user).

 

Best,

Dávid

You could do this be creating a custom matrix with a slicer for columns:

https://community.powerbi.com/t5/Community-Blog/Creating-a-custom-or-hybrid-matrix-in-PowerBI/ba-p/1... 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@dfarkas , You need to unpivot the columns and they will become row values, You can use them in the slicer and matrix column.

 

 

refer if needed

 

Dynamically change chart axis in Power BI
bookmark -https://blog.crossjoin.co.uk/2018/04/20/dynamically-changing-a-chart-axis-in-power-bi-using-bookmarks-and-buttons/
https://radacad.com/bookmarks-and-buttons-making-power-bi-charts-even-more-interactive
https://www.youtube.com/watch?v=6jeSIRpjv0M
https://datamonkeysite.com/2020/10/22/change-dimension-dynamically-using-parameter-in-powerbi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks, @amitchandak

This was the first solution I tried and unfortunately this doesn't suit my requirements. The main problem is that this is an additive solution and does not do any cross-tabulation.

 

This is the output from this solution (N = 10):

Column 1    Count

cat               3

dog             7

Column 2

male           5

female        5

 

Total           20

 

Instead, I'm looking for an output like this:

Column 1    Column 2    Count

cat               male            2

cat               female         4

dog             male            1

dog             female         3

Total                               10

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.