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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
JonnyOh
Regular Visitor

Default Selection in Bar Chart

Hello,

 

I have two bar charts (SectorReturns on left and ReturnAttribution on right in image below) that are to be filtered by sector (materials, industrials, consumer disc., etc.).

Screenshot 2021-09-22 083138.png

 

 

 

 

 

 

 

 

 

 

 

 

I have the filtering in place however, I want the ReturnAttribution bar chart to default to the "portfolio" sector and not show the overall attribution by sector. For example for Materials below the filtering for each sector is in place but when nothing is selected in the SectorReturns bar chart, I want the same thing as below to show for the "portfolio" sector. 

Screenshot 2021-09-22 083515.png

 

Additionally, having a data label issue where I don't want the materials label to show in the y-axis for the ReturnAttribution chart. Each bar represents Excess Return, Style, Industry and Selection Effect. I want these labels to show. Table is set up like this:

Screenshot 2021-09-22 083834.png

 

Thanks!

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @JonnyOh 

 

My approach is through measures.

First you have to create 4 measures instead of 4 columns to get a dynamic display.

The 4 measures are basically the same, except that the referenced columns are different.

before you do this, create a table with this formula

Table 2 = VALUES('Table'[Sector])

 

4 measure:

M Excess Return =
VAR _selected =
    CALCULATE (
        SUM ( 'Table'[Excess Retrun] ),
        FILTER ( 'Table', [Sector] = SELECTEDVALUE ( 'Table 2'[Sector] ) )
    )
VAR _no_selected =
    CALCULATE (
        SUM ( 'Table'[Excess Retrun] ),
        FILTER ( 'Table', [Sector] = "Portfolio" )
    )
VAR _IFselected =
    MAX ( 'Table 2'[Sector] ) = SELECTEDVALUE ( 'Table'[Sector] )
RETURN
    IF (
        _IFselected,
        _selected,
        IF ( MAX ( 'Table 2'[Sector] ) = "Portfolio", _no_selected, BLANK () )
    )

MIndustry =
VAR _selected =
    CALCULATE (
        SUM ( 'Table'[Industry] ),
        FILTER ( 'Table', [Sector] = SELECTEDVALUE ( 'Table'[Sector] ) )
    )
VAR _no_selected =
    CALCULATE (
        SUM ( 'Table'[Industry] ),
        FILTER ( 'Table', [Sector] = "Portfolio" )
    )
VAR _IFselected =
    MAX ( 'Table 2'[Sector] ) = SELECTEDVALUE ( 'Table'[Sector] )
RETURN
    IF (
        _IFselected,
        _selected,
        IF ( MAX ( 'Table 2'[Sector] ) = "Portfolio", _no_selected, BLANK () )
    )

MSelection =
VAR _selected =
    CALCULATE (
        SUM ( 'Table'[Selection] ),
        FILTER ( 'Table', [Sector] = SELECTEDVALUE ( 'Table'[Sector] ) )
    )
VAR _no_selected =
    CALCULATE (
        SUM ( 'Table'[Selection] ),
        FILTER ( 'Table', [Sector] = "Portfolio" )
    )
VAR _IFselected =
    MAX ( 'Table 2'[Sector] ) = SELECTEDVALUE ( 'Table'[Sector] )
RETURN
    IF (
        _IFselected,
        _selected,
        IF ( MAX ( 'Table 2'[Sector] ) = "Portfolio", _no_selected, BLANK () )
    )

MStyle =
VAR _selected =
    CALCULATE (
        SUM ( 'Table'[Style] ),
        FILTER ( 'Table', [Sector] = SELECTEDVALUE ( 'Table'[Sector] ) )
    )
VAR _no_selected =
    CALCULATE ( SUM ( 'Table'[Style] ), FILTER ( 'Table', [Sector] = "Portfolio" ) )
VAR _IFselected =
    MAX ( 'Table 2'[Sector] ) = SELECTEDVALUE ( 'Table'[Sector] )
RETURN
    IF (
        _IFselected,
        _selected,
        IF ( MAX ( 'Table 2'[Sector] ) = "Portfolio", _no_selected, BLANK () )
    )

 

After this, do filter via the slicer visual.

Here is my pbix file you can reference.

 

Best Regards

Community Support Team _ chenwu zhu

 

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

1 REPLY 1
v-chenwuz-msft
Community Support
Community Support

Hi @JonnyOh 

 

My approach is through measures.

First you have to create 4 measures instead of 4 columns to get a dynamic display.

The 4 measures are basically the same, except that the referenced columns are different.

before you do this, create a table with this formula

Table 2 = VALUES('Table'[Sector])

 

4 measure:

M Excess Return =
VAR _selected =
    CALCULATE (
        SUM ( 'Table'[Excess Retrun] ),
        FILTER ( 'Table', [Sector] = SELECTEDVALUE ( 'Table 2'[Sector] ) )
    )
VAR _no_selected =
    CALCULATE (
        SUM ( 'Table'[Excess Retrun] ),
        FILTER ( 'Table', [Sector] = "Portfolio" )
    )
VAR _IFselected =
    MAX ( 'Table 2'[Sector] ) = SELECTEDVALUE ( 'Table'[Sector] )
RETURN
    IF (
        _IFselected,
        _selected,
        IF ( MAX ( 'Table 2'[Sector] ) = "Portfolio", _no_selected, BLANK () )
    )

MIndustry =
VAR _selected =
    CALCULATE (
        SUM ( 'Table'[Industry] ),
        FILTER ( 'Table', [Sector] = SELECTEDVALUE ( 'Table'[Sector] ) )
    )
VAR _no_selected =
    CALCULATE (
        SUM ( 'Table'[Industry] ),
        FILTER ( 'Table', [Sector] = "Portfolio" )
    )
VAR _IFselected =
    MAX ( 'Table 2'[Sector] ) = SELECTEDVALUE ( 'Table'[Sector] )
RETURN
    IF (
        _IFselected,
        _selected,
        IF ( MAX ( 'Table 2'[Sector] ) = "Portfolio", _no_selected, BLANK () )
    )

MSelection =
VAR _selected =
    CALCULATE (
        SUM ( 'Table'[Selection] ),
        FILTER ( 'Table', [Sector] = SELECTEDVALUE ( 'Table'[Sector] ) )
    )
VAR _no_selected =
    CALCULATE (
        SUM ( 'Table'[Selection] ),
        FILTER ( 'Table', [Sector] = "Portfolio" )
    )
VAR _IFselected =
    MAX ( 'Table 2'[Sector] ) = SELECTEDVALUE ( 'Table'[Sector] )
RETURN
    IF (
        _IFselected,
        _selected,
        IF ( MAX ( 'Table 2'[Sector] ) = "Portfolio", _no_selected, BLANK () )
    )

MStyle =
VAR _selected =
    CALCULATE (
        SUM ( 'Table'[Style] ),
        FILTER ( 'Table', [Sector] = SELECTEDVALUE ( 'Table'[Sector] ) )
    )
VAR _no_selected =
    CALCULATE ( SUM ( 'Table'[Style] ), FILTER ( 'Table', [Sector] = "Portfolio" ) )
VAR _IFselected =
    MAX ( 'Table 2'[Sector] ) = SELECTEDVALUE ( 'Table'[Sector] )
RETURN
    IF (
        _IFselected,
        _selected,
        IF ( MAX ( 'Table 2'[Sector] ) = "Portfolio", _no_selected, BLANK () )
    )

 

After this, do filter via the slicer visual.

Here is my pbix file you can reference.

 

Best Regards

Community Support Team _ chenwu zhu

 

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors