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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Pbiuserr
Post Prodigy
Post Prodigy

Chart is not affected by the filters

Hello, 
I had a requirement to create a chart which would give 3 years based on user selection (so user selects 05.2018 and I got axis of 05.2016, 05.2017, 05.2018 etc). for that purpose I had to create 2nd calendar without connection to anything to let it be an axis, and the measure is 

Last 3 year HC =
VAR _CurrentYear = YEAR(MAX('Calendar'[Date]))
VAR _CurrnetMonth = MONTH(MAX('Calendar'[Date]))
VAR _DateTable =
              FILTER(
                         SUMMARIZE('Calendar2',
                         Calendar2[YEAR],
                         Calendar2[MONTH]
                            ),
                             Calendar2[YEAR] <= _CurrentYear && Calendar2[YEAR] > _CurrentYear -3
                             && Calendar2[MONTH] = _CurrnetMonth
                             )
VAR _Relation =
                        TREATAS(
                       _DateTable,'Calendar'[Year],'Calendar'[Month])
VAR _Result =
                          CALCULATE(
                                     [Measure],
                                      _Relation,
                                       REMOVEFILTERS()
                                        )
RETURN
_Result


works like charm on calendar slicer, but when I want to slice by other columns like idk Department, Gender etc.. the chart stay as it is.. is there any way to enable filtering and still maintain chart being 2 years prior?
1 ACCEPTED SOLUTION

Hello,
My solution to that is just to REMOVEFILTERS from entire calendar table, not only column Year and/or month so REMOVEFILTERS('Calendar') solves the problem

View solution in original post

6 REPLIES 6
v-yiruan-msft
Community Support
Community Support

Hi  @Pbiuserr ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create one calendar table

2.Create a measure  as below:

Measure = 
VAR _selym =
    SELECTEDVALUE ( 'Calendar'[YearMonth] )
VAR _year =
    VALUE ( LEFT ( _selym, 4 ) )
VAR _month =
    VALUE ( RIGHT ( _selym, 2 ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER (
            'Table',
            YEAR ( 'Table'[Date] ) <= _year
                && YEAR ( 'Table'[Date] ) >= _year - 2
                && MONTH ( 'Table'[Date] ) = _month
        )
    )

yingyinr_0-1652425838538.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Hello,
My solution to that is just to REMOVEFILTERS from entire calendar table, not only column Year and/or month so REMOVEFILTERS('Calendar') solves the problem

johnt75
Super User
Super User

The issue is the REMOVEFILTERS - that is clearing all filters across all tables, so its ignoring any slicers. As you said that your new table isn't connected to anything else then it wouldn't be filtering anything else, you may be able to remove the REMOVEFILTERS altogether. 

If there are specific tables or columns you want to remain as active filters then you could specify them in ALLEXCEPT calls, or if there are specific tables from which you do want to remove filters then specify those inside the REMOVEFILTERS

So it would be like 

VAR _Result =
                          CALCULATE(
                                     [Measure],
                                      _Relation,
                                       REMOVEFILTERS( ALLEXCEPT ( FactTable, FactTable[Category]))
                                        )
this will make FactTable[Category] in slicer make changes to chart?
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

@Pbiuserr - The REMOVEFILTERS will remove filters.  Consider changing to REMOVEFILTERS( 'Calendar'[Year],'Calendar'[Month] )?

REMOVEFILTERS( 'Calendar'[Year],'Calendar'[Month] ) or just REMOVEFILTERS( 'Calendar'[Year]) makes chart filter only selected period on filter (not giving years back)

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.