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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
mrfsca
Frequent Visitor

Trouble creating slicers for stacked bar chart from across the table

Hello, I'm having trouble creating a line and stacked bar chart. Here's the scenario: I have three tables with some common columns, and each table has an "LP" column indicating the location of the data. The LP columns in the tables contain BR, LR, and LB, respectively. My goal is to use these three columns as slicers. I found a suggestion in the Power BI community, which is:

Plant = DISTINCT(UNION(SELECTCOLUMNS('BR',"LP",'BR'[LP]),SELECTCOLUMNS('LR',"LP",'LR'[LP]),SELECTCOLUMNS('LB',"LP",'LB'[LP])))

However, I'm not sure how to apply this as a slicer because when I try it, there are no changes in the chart. Additionally, I want to create another slicer where users can select which variables to include in the stacked bar chart. Specifically, I have four variables: cost A, cost B, cost C, and cost D, which contain numerical values. Should I insert those fields from each tables in the column y axis to get what I want? The chart should only display the values for a single plant. Please provide suggestions so that I can achieve my desired outcome. Thanks in advance

mrfsca_1-1687671610874.png 

mrfsca_2-1687671746064.png

 

 

 

 

 

1 ACCEPTED SOLUTION
rbriga
Impactful Individual
Impactful Individual

Regarding costs

Unpivot the table- either at the source, or in the Query Editor:

1. Right click the table, then Edit query

2. Select your costs columns 

3. Follow this example

Now you have a dimension (Costs) which you can use as a slicer.

Unpivot costsUnpivot costsVictory!Victory!

I admit that I don't understand the LP table(s) just yet.

Perhaps I'd need the dataset itself to help further.

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!

View solution in original post

4 REPLIES 4
rbriga
Impactful Individual
Impactful Individual

Regarding costs

Unpivot the table- either at the source, or in the Query Editor:

1. Right click the table, then Edit query

2. Select your costs columns 

3. Follow this example

Now you have a dimension (Costs) which you can use as a slicer.

Unpivot costsUnpivot costsVictory!Victory!

I admit that I don't understand the LP table(s) just yet.

Perhaps I'd need the dataset itself to help further.

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!
mrfsca
Frequent Visitor

Thank you for resolving the issue I had. As for the LP table, it has been resolved by manually creating a combination table by merging the three tables together.

 

rbriga
Impactful Individual
Impactful Individual

Can you share the 2 tables structure with 3-4 rows of data each?

I suspect we would need to UNION these tables at the source with a column to seperate them into categories (BR, LR, and LB).

Then we will have 1 table to work with, and its colums will be functioning slicers.

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!
mrfsca
Frequent Visitor

Hello, this is the Cost A, B, C, D, and the LP preview table. Each table such as LR, BR, and LB has the same structure as this figure below. 

mrfsca_0-1687886170918.png 

mrfsca_2-1687886410022.png

 

 

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors