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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Column chart based on filter selection

Hello,

 

I need a graph on my dashboard to have a variable column based on the selection made in a filter.

I managed to achieve this through a method I found on the internet where I create an intermediate table and connect the filter table with the dimension that has the columns I need in the graph:

 

Sem título.png

 

I created a formula where I list the column I need based on the selection made in the filter:

 

Semana Selecionada =
SWITCH('Semanas x Datas'[Semanas],
"Termina Segunda", RELATED(Dim_Calendario[Termina Segunda]),
"Termina Terça", RELATED(Dim_Calendario[Termina Terça]),
"Termina Quarta", RELATED(Dim_Calendario[Termina Quarta]),
"Termina Quinta", RELATED(Dim_Calendario[Termina Quinta]),
"Termina Sexta", RELATED(Dim_Calendario[Termina Sexta])
)

 

The method worked and the column that appears in my graph is exactly the column that I selected in the filter, however the data order was completely random, I had configured the order that the columns should have in the data part of the power bi, but this function it is disregarding the order that I had configured for the columns.

 

How do I make this function maintain the order that I determined for the columns?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , If it is a column. Create one more column, in the same manner, having sort order of these columns and mark that as a sort column

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Does anyone know if there is any way to maintain the order of the columns in this type of graph?

amitchandak
Super User
Super User

@Anonymous , If it is a column. Create one more column, in the same manner, having sort order of these columns and mark that as a sort column

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

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
Anonymous
Not applicable

I didn't understand what you said, but now I understood and it worked perfectly, thank you very much

Anonymous
Not applicable

This method is not working in this case, each column of the switch has a specific column to determine its order, here's an example:

 

Sem título.png

 

The column highlighted in red "Termina Quinta" is ordered by the column highlighted in green "IQuinta", the column highlighted in purple "Termina Segunda" is highlighted by the column highlighted in blue "ISegunda", the same goes for the other columns.

 

The column that is used in my graph depends on the selection I make in the filter, for example, if I select "Termina Segunda" in the filter the graph will use the column Dim_Calendario [Termina Segunda] in the graph, following image to illustrate:

 

Sem título1.png

 

The column used in the graph is generated by the formula:

 

Semana Selecionada =
SWITCH('Semanas x Datas'[Semanas],
"Termina Segunda", RELATED(Dim_Calendario[Termina Segunda]),
"Termina Terça", RELATED(Dim_Calendario[Termina Terça]),
"Termina Quarta", RELATED(Dim_Calendario[Termina Quarta]),
"Termina Quinta", RELATED(Dim_Calendario[Termina Quinta]),
"Termina Sexta", RELATED(Dim_Calendario[Termina Sexta])
)

 

When I select the column in the filter the graph shows the respective column but in a totally random order, it does not respect the order that I determined for the columns in the table "Dim_Calendario".

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.