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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
data4good
Frequent Visitor

How to make a clustered column chart with multiple fields

Hello,

 

I am trying to build a frequency chart to show the total number of each resource type that staff provided (e.g. # of basic needs resources, # of diapers resources, # of childcare resources, etc).

I started with a table of all resources provided. I then created calculated fields for each type of resource, so that each resource type is a binary (1 = true 0 = false).

I then put each of these calculated fields into a clustered column chart. When I set the y axis to 'sum', I get the right values (ie. a count of all the 1's), but the chart doesn't look good. I read something about creating a text index field to put in the x-axis, so I just created a dummy variable where all rows = "Number of Referrals". However, this didn't really help much. There aren't any labels along the x axis and the labels above look clunky. There's also still a lot of white space to the left and right of the columns  that I can't get rid of.

Is there a better approach to do this? I see many people posting the same question, but haven't found a workable solution! 

 

data4good_0-1737829373641.png

 

In case it's relevant, I'm working in a report that uses the above semantic model as my data source, so I have to go back to the semantic model file to edit the query.

 

Thanks for any assistance you can offer!

2 ACCEPTED SOLUTIONS
v-linyulu-msft
Community Support
Community Support

Thanks for the reply from MockIT2As and Fowmy , please allow me to provide another insight:

Hi, @data4good 
Thanks for reaching out to the Microsoft fabric community forum.

First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1737959485854.png

Here are the detailed steps for your reference, which I hope will help you proceed more clearly:

1.Firstly, copy the query.In Power Query, right-click the original query and select "Duplicate.

vlinyulumsft_1-1737959485855.png

This preserves the original data, avoiding risks associated with direct modifications.

2.Secondly, Unpivot operation:Select all columns except the "Employee" column and choose "Unpivot Columns."

vlinyulumsft_2-1737959530680.png

vlinyulumsft_3-1737959530681.png

This converts the data from a wide table to a long table format, making it easier to analyze.

3,Next, create a bar chart.In Power BI Desktop, select the bar chart visualization.

vlinyulumsft_4-1737959553707.png

 

Drag the "Attribute" field to the X-axis.

4.Then, modify visualization settings:

Change bar chart colors.Create a new measure to define colors for different categories.

ColorCode =
SWITCH (
    MAX ( 'Table (2)'[Attribute] ),
    "Basic Needs", "#FF5733",
    "Diapers", "#33FF57",
    "Childcare", "#3357FF",
    "Food", "#FF33A6",
    "Clothing", "#FFC300",
    "#FFFFFF"
)

 

vlinyulumsft_5-1737959582810.png

vlinyulumsft_6-1737959582810.png

Modify visualization title.In the "Format" tab, find "Title" and enter the new title text.

vlinyulumsft_7-1737959595605.png

Add column titles.In the "Format" tab, find "Data Labels," enable them, and set the label format.

vlinyulumsft_8-1737959595606.png

Remove the title from the x and y axes.

vlinyulumsft_9-1737959630777.png

5.Here's my final result, which I hope meets your requirements.

vlinyulumsft_10-1737959641083.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

View solution in original post

Ah thank you so much! Your response made me realize the step I was missing, and it was actually even simpler than what you laid out. I actually already had a table of data in long format, and I had used calculated columns to create a series of boolean columns. Following your logic, I was able to create an additional calculated column that combined all the boolean columns. Thank you!!

View solution in original post

4 REPLIES 4
v-linyulu-msft
Community Support
Community Support

Thanks for the reply from MockIT2As and Fowmy , please allow me to provide another insight:

Hi, @data4good 
Thanks for reaching out to the Microsoft fabric community forum.

First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1737959485854.png

Here are the detailed steps for your reference, which I hope will help you proceed more clearly:

1.Firstly, copy the query.In Power Query, right-click the original query and select "Duplicate.

vlinyulumsft_1-1737959485855.png

This preserves the original data, avoiding risks associated with direct modifications.

2.Secondly, Unpivot operation:Select all columns except the "Employee" column and choose "Unpivot Columns."

vlinyulumsft_2-1737959530680.png

vlinyulumsft_3-1737959530681.png

This converts the data from a wide table to a long table format, making it easier to analyze.

3,Next, create a bar chart.In Power BI Desktop, select the bar chart visualization.

vlinyulumsft_4-1737959553707.png

 

Drag the "Attribute" field to the X-axis.

4.Then, modify visualization settings:

Change bar chart colors.Create a new measure to define colors for different categories.

ColorCode =
SWITCH (
    MAX ( 'Table (2)'[Attribute] ),
    "Basic Needs", "#FF5733",
    "Diapers", "#33FF57",
    "Childcare", "#3357FF",
    "Food", "#FF33A6",
    "Clothing", "#FFC300",
    "#FFFFFF"
)

 

vlinyulumsft_5-1737959582810.png

vlinyulumsft_6-1737959582810.png

Modify visualization title.In the "Format" tab, find "Title" and enter the new title text.

vlinyulumsft_7-1737959595605.png

Add column titles.In the "Format" tab, find "Data Labels," enable them, and set the label format.

vlinyulumsft_8-1737959595606.png

Remove the title from the x and y axes.

vlinyulumsft_9-1737959630777.png

5.Here's my final result, which I hope meets your requirements.

vlinyulumsft_10-1737959641083.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

Ah thank you so much! Your response made me realize the step I was missing, and it was actually even simpler than what you laid out. I actually already had a table of data in long format, and I had used calculated columns to create a series of boolean columns. Following your logic, I was able to create an additional calculated column that combined all the boolean columns. Thank you!!

MockIT2As
New Member

  • You can do a variable data form next to the graph, and extract the results onto the bar graph and the x and y axis labeled with the title from the chart. Since only 2 resulting you would need to show how you got the results onto the bar chart by doing a results table.
  • I hope this helps.
Fowmy
Super User
Super User

@data4good 

I would suggest Clustered Bar Chart  where the lables show up clearly. additionally, you may remove X and Y Axis values and Titles and use the title to provide details. Finally, set the Space Between Categories to 0% under Bar Options.

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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