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
sonali_powerbi
Regular Visitor

stacked column display does not change with slicer

Hello, 

 

I have a slicer that I would like to control two charts: a stacked bar chart, and a clustered bar chart. I only want to display the latest 12 months data. The clustered bar chart behaves as expected, displaying only that data. 

 

The stacked bar chart though, displays only the data for the last 12 months, but keeps all values of months, with nothing displayed for months that do not match the slicer condition. 

 

I would like the stacked bar chart to match the display for the clustered bar chart, and not even display the older months, as they contain no information. I include a screenshot below. Can someone please help me figure this out?

 

Thanks!

 

StackedColumnSlicerIssue.png

 

1 ACCEPTED SOLUTION

Hi sonali_powerbi,

 

>> So if I have a similar table B, I cannot link YearMonth columns in the two tables, as it will be a many-many connection.

 

I’d like to suggest you use CALENDAR function to add ‘CALENDAR’ table to link other tables which contains the data column.

 

Below is the Sample:

 

1. Build two tables to test.

 

‘DateAmount’

 Capture.PNG

‘MasterYearMonth’

 Capture2.PNG

2. Add a calendar Table with date from above tables, and create relationships among those tables. (Since both tables contain the duplicate records, it’s not able to build a relationship.)

 

Dax:  CALENDARTable = CALENDAR(MIN(MIN(DateAmount[Date]),MIN(MasterYearMonth[Date])),MAX(MAX(DateAmount[Date]),MAX(MasterYearMonth[Date])))

 Capture3.PNG

 

Create the relationship:

 Capture4.PNG

 

3. Use Calendar table to filter the records.(Below is the visual’s struct and screenshots)

 

Stacked bar chart:

 Capture5.PNG

Capture6.PNG

Clustered bar chart:

 Capture7.PNG

Capture8.PNG

 

Slicer:

 Capture9.PNG

Capture10.PNG

 

Use slicer to filter both table:

 Capture11.PNG

If above is not help, please provide more detial and feel free to let me know.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
sonali_powerbi
Regular Visitor

I think I missed a crucial piece of information - I am trying to control the two charts with a slicer from another table that is linked to the table used for making the charts. If I use a slicer from the same table, it works. 

 

I will need to use the other table though, as the YearMonth value in my data table is not unique, and I want to connect multiple tables. So I am trying to create a MasterYearMonth table, which will have unique YearMonth values, which can then connect to multiple tables. I want the slicer to be from the MasterYearMonth table, which is creating the messed up display explained above. 

 

So, I have table A:

 

Date      YearMonth     AValue

3/15/16  2016-03         10.3

3/24/16   2016-03        15.2

...

...

...

 

Note the YearMonth value is not unique. So if I have a similar table B, I cannot link YearMonth columns in the two tables, as it will be a many-many connection. This is the background reason why I want to link a slicer from a different table, but I haven't gotten as far as table B yet. 🙂 

 

Hence, I am creating a MasterYearMonth table, which only has each YearMonth value once. Then my Rolling12MonthFlag is defined in the MasterYearMonth table, which can control data from tables A, B, .. 

 

Both the plots shown above come from the same table, table A. If I have a slicer Rolling12MonthsFlag also defined in table A, it works as desired. If I define the slicer in the MasterYearMonth table, it does not seem to control the stacked bar chart properly. This is my issue. 

 

Here is a screenshot of how things work well with slicer from table A. I would like a display like this even when my slicer is from the MasterYearMonth table. 

 

Thanks so much to whoever is still reading. 🙂

 

StackedColumnSameTableSlicerWorks.png

 

Hi sonali_powerbi,

 

>> So if I have a similar table B, I cannot link YearMonth columns in the two tables, as it will be a many-many connection.

 

I’d like to suggest you use CALENDAR function to add ‘CALENDAR’ table to link other tables which contains the data column.

 

Below is the Sample:

 

1. Build two tables to test.

 

‘DateAmount’

 Capture.PNG

‘MasterYearMonth’

 Capture2.PNG

2. Add a calendar Table with date from above tables, and create relationships among those tables. (Since both tables contain the duplicate records, it’s not able to build a relationship.)

 

Dax:  CALENDARTable = CALENDAR(MIN(MIN(DateAmount[Date]),MIN(MasterYearMonth[Date])),MAX(MAX(DateAmount[Date]),MAX(MasterYearMonth[Date])))

 Capture3.PNG

 

Create the relationship:

 Capture4.PNG

 

3. Use Calendar table to filter the records.(Below is the visual’s struct and screenshots)

 

Stacked bar chart:

 Capture5.PNG

Capture6.PNG

Clustered bar chart:

 Capture7.PNG

Capture8.PNG

 

Slicer:

 Capture9.PNG

Capture10.PNG

 

Use slicer to filter both table:

 Capture11.PNG

If above is not help, please provide more detial and feel free to let me know.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

This works, Xiaoxin. Thank you so much. 

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.